/** * This class is designed to play a game of PseudoWar * * * @author:Elizabeth Adams * date: * lab2 * section * */ public class PseudoWar { private int score1, score2; private String player1, player2; private int numberRounds; /** This is the constructor for pseudoWar * It sets the class attributes * * @param name1 user's choice of name for first player * @param name2 user's choice of name for second player * @param numRounds number of rounds user want the game to contain */ public PseudoWar (String name1, String name2, int numRounds) { // sets the name of the first player // sets the name of the second player // initialize players' scores to 0 // sets the number of rounds } // end constructor /** * This method prints the heading for the output * * */ public void startGame() { // prints the heading // calls playGame } // end startGame /** * This method runs the game and prints the * output of each round and the echo of users * values * * */ public void playGame () { // calls runRound // outputs the results returned to it by runRound } // end playGame /** * * This method generates a random number in the * range 1 to 52 and returns it. * * @return random number in range 1 to 52 * * */ public int generateNumber () { // call random number generator in Math class which returns a // a double number between 0 and 1 // manipulate the number returned until it’s between 1 and 52 // multiply it by 52, add 1, and cast it to an integer return 786; } // end generateNumber /** * This method receives two random numbers, the * first belonging to player 1, the second to player 2 * compares the numbers * * @param num1 first player's number * @param num2 second player's number * * @return 1 if player1's number is higher * 2 if player2's number is higher * 0 if the numbers of the two players are the same */ public int determineWinner ( int num1, int num2) { return 23; } // end determine winner /** * This method calls generateNumber and determineWinner * and updates the player's scores and returns a String * with the appropriate round String to playGame * * @return result of the round to be put in output table */ public String runRound () { // call generateNumber for each player // call determineWinner // update score of winner (an attribute) // compose and return a String to playGame showing player values and winner return "runRound"; } // end runRound /** * * this method returns a string with the final output * including the final game results to main * * @return final results */ public String getFinalResult () { return "finalResult"; } //end getFinalResult } // end PseudoWar