Hw4 - 4 The main thing you have to do is to add a new accessor method to CrapsGame called getGameInProgress that returns the value of

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS112: Homework #4 1. We will make a version of the rolling-dice project to include keyboard interaction. The goal is to have functionality where the user has to just keep hitting return to make the dice rolls. See the example screen output. 2. Add a new class called Interaction to the project. 3. Type the Interaction code … (Yes, the whole code is provided for you!) import java.util.*; public class Interaction { private Scanner keyboard; private CrapsGame game; public Interaction() { keyboard = new Scanner(System.in); game = new CrapsGame(); } public void run() { String anyInput; System.out.print("Hit Return to roll. .."); anyInput = keyboard.nextLine(); //This reads the typed line. game.rollTheDice(); //if the game is in progress, //call the run method again! if(game.getGameInProgress()){ run(); }else{ System.out.println("=== GAME OVER ===");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } } } 4. The main thing you have to do is to add a new accessor method to CrapsGame called getGameInProgress() that returns the value of gameInProgress . 5. Compile and test. 6. You can modify the CrapsGame method beginGame() so it prints “*** New Game ***” at the beginning of a game. 7. Organize your rolling-dice project so it looks something like this: 8. Modify the run() method so that if the user types in the word “a”, the game is aborted. That is, the method would stop immediately with a message to the effect that the game was aborted. See example run below. String equality is testing the following way, not with ==, if(anyInput.equals("a")) 9. Put your name and date as a comment at the top of each class file. 10. Turn in a print out of all four class files....
View Full Document

This lab report was uploaded on 04/08/2008 for the course CSCI 112 taught by Professor Yuen during the Fall '07 term at Lake Forest.

Page1 / 2

Hw4 - 4 The main thing you have to do is to add a new accessor method to CrapsGame called getGameInProgress that returns the value of

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online