mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 07:29:02 -08:00
Moving re-playability to other script
This commit is contained in:
@@ -9,9 +9,9 @@ public class HighIQ {
|
||||
private PrintStream out;
|
||||
private Scanner scanner;
|
||||
|
||||
public HighIQ() {
|
||||
public HighIQ(Scanner sccanner) {
|
||||
out = System.out;
|
||||
scanner = new Scanner(System.in);
|
||||
this.scanner = scanner;
|
||||
board = new HashMap<>();
|
||||
|
||||
//Set of all locations to put initial pegs on
|
||||
@@ -26,6 +26,7 @@ public class HighIQ {
|
||||
board.put(41, false);
|
||||
}
|
||||
|
||||
|
||||
public boolean move() {
|
||||
System.out.println("MOVE WHICH PIECE");
|
||||
int from = scanner.nextInt();
|
||||
@@ -62,7 +63,6 @@ public class HighIQ {
|
||||
}
|
||||
|
||||
public void play() {
|
||||
do {
|
||||
do {
|
||||
while(!move()) {
|
||||
System.out.println("ILLEGAL MOVE, TRY AGAIN...");
|
||||
@@ -83,14 +83,12 @@ public class HighIQ {
|
||||
out.println("SAVE THIS PAPER AS A RECORD OF YOUR ACCOMPLISHMENT!");
|
||||
}
|
||||
|
||||
} while(playAgain());
|
||||
out.println("SO LONG FOR NOW.");
|
||||
}
|
||||
|
||||
private boolean playAgain() {
|
||||
out.println("PLAY AGAIN (YES OR NO)");
|
||||
return scanner.nextLine().toLowerCase().equals("yes");
|
||||
}
|
||||
// private boolean playAgain() {
|
||||
// out.println("PLAY AGAIN (YES OR NO)");
|
||||
// return scanner.nextLine().toLowerCase().equals("yes");
|
||||
// }
|
||||
|
||||
|
||||
public boolean isGameFinished() {
|
||||
|
||||
Reference in New Issue
Block a user