CS 145 Lecture 19 – Looping II
Agenda
- what ?s
- predicate chain game
- program this
- loops driven by user input
- sharing birthdays
- for loops
Predicate Chain Game
- 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?
- 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.
- 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.