teaching machines

CS 145 Lecture 19 – Looping II

October 15, 2014 by . Filed under cs145, fall 2014, lectures.

Agenda

Predicate Chain Game

  1. Decide upon a yes-or-no that you can ask about someone–a predicate. If you were to ask yourself this question, you would say yes. For example: Are you related to Abraham Lincoln?
  2. Ask your right-neighbor this question. If your right neighbor is a wall or aisle, ask the closest person in the row behind you. If you are in the last row, ask the closest person in the row in front of you. If that person says yes, that person carries the question to the next neighbor. Continue until you hit a no.
  3. Count how long your chain of yeses is.

Program This

Write a method times that accepts a character and a count. Return a String containing a sequence of the character repeated count times.