sjm.examples.karate
Class KaratePuzzle
java.lang.Object
|
+--sjm.examples.karate.KaratePuzzle
- public class KaratePuzzle
- extends java.lang.Object
Each of four martial arts students has a different
specialty. From the following clues, can you determine
each student’s full name and her special skill?
- Ms. Ellis (whose instructor is Mr. Caldwell), Amy, and
Ms. Fowler are all martial arts students.
- Sparring isn’t the specialty of either Carla or
Dianne.
- Neither the shoot-fighting expert nor the pressure
point fighter is named Fowler.
- Children’s techniques aren’t the specialty of Dianne
(whose instructor is Ms. Sherman).
- Amy, who disdains pressure point fighting, isn’t
Ms. Goodrich.
- Betti and Ms. Fowler are roommates.
- Ms. Hightower avoids sparring because of its point
scoring nature.
|
Method Summary |
protected void |
assembleStudents(java.lang.Object[] lasts,
java.lang.Object[] specs)
|
protected boolean |
cluesVerify()
|
static void |
main(java.lang.String[] args)
Solve the karate puzzle. |
protected void |
showStudents()
|
protected void |
solve()
Generate all permutations of last names and specialties,
and check each arrangement to see if it passes all the
clues that the puzzle specifies. |
protected Student |
studentNamed(java.lang.String lastName)
Return the Student who has the given last name |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
amy
protected Student amy
betti
protected Student betti
carla
protected Student carla
dianne
protected Student dianne
students
protected Student[] students
lastNames
protected java.lang.String[] lastNames
specialties
protected java.lang.String[] specialties
KaratePuzzle
public KaratePuzzle()
assembleStudents
protected void assembleStudents(java.lang.Object[] lasts,
java.lang.Object[] specs)
cluesVerify
protected boolean cluesVerify()
- Returns:
- true, if the student objects meet all the clues
in the puzzle
main
public static void main(java.lang.String[] args)
throws CombinatoricException
- Solve the karate puzzle.
- Throws:
- CombinatoricException - Shouldn't happen
showStudents
protected void showStudents()
solve
protected void solve()
throws CombinatoricException
- Generate all permutations of last names and specialties,
and check each arrangement to see if it passes all the
clues that the puzzle specifies.
- Throws:
- CombinatoricException - Shouldn't happen
studentNamed
protected Student studentNamed(java.lang.String lastName)
- Return the Student who has the given last name
- Parameters:
lastName - String- Returns:
- Student, the Student with the given last name