Guest User

Liars Dice Driver

a guest
Oct 22nd, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.33 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Driver {
  5.  
  6.     // create a static instance of the LiarDic class
  7.     static LiarDice myDice = new LiarDice();
  8.    
  9.     public static void main(String[] args)
  10.     {
  11.         // create a variable named answer with the type String
  12.        
  13.         // call the Roll method from the LiarDice class
  14.  
  15.        
  16.         // call the incraseNumberOfRolls in the LiarDice class
  17.        
  18.        
  19.         // call the showCurrentDice method
  20.        
  21.        
  22.         // print out an extra line
  23.         System.out.println("");
  24.        
  25.         // create a do loop
  26.         do{
  27.            
  28.         // call the showMenu method
  29.        
  30.        
  31.         // create an instance of the scanner class
  32.        
  33.        
  34.         // get the user;s choice by calling nextInt
  35.        
  36.         // get the return key
  37.        
  38.         // check to see if the user's choice is 1
  39.        
  40.             // call make claim
  41.        
  42.         // check to see if the user's choice is 2
  43.        
  44.        
  45.             // check to see if the number of rolls is less than 3
  46.        
  47.                 // if it's less than 3 then call the Roll method in the LiarsDice class
  48.        
  49.             // otherwise
  50.        
  51.                 // print a message that says they cannot make any more rolls
  52.        
  53.        
  54.             // call the showCurrentDice method
  55.        
  56.        
  57.         // check to see if the user's choice is 3
  58.        
  59.             // call the saveDice method
  60.        
  61.         // check to see if the user's choice is 4
  62.        
  63.             // call the showCurrentDice method
  64.                
  65.         // check to see if the user's choice is 5
  66.        
  67.        
  68.             // print out a message asking if they have won or lost
  69.        
  70.             // get an integer that from the scanner
  71.        
  72.             // get the enter key
  73.        
  74.             // check to see if the integer entered was 1
  75.        
  76.                 // if it was one, call the increaseWins from the LiarsDice class
  77.        
  78.        
  79.                 // otherwise, call the increaseLosses from the LiarsDice class
  80.        
  81.            
  82.             // call resetGame from the LiarsDice class
  83.        
  84.            
  85.         // check to see if the user's choice is 6
  86.        
  87.    
  88.             // print out a summary of the wins and losses
  89.             // call the toString from the LiarsDice class
  90.    
  91.    
  92.    
  93.         // check to see if the user's choice is 7
  94.    
  95.        
  96.             // the resetGame from the LiarsDice class
  97.        
  98.             // call the Roll method from the LiarsDice class
  99.        
  100.             // call the showCurrentDice method
  101.        
  102.        
  103.         // otherwise, just say, try again.
  104.        
  105.        
  106.             // print a method that says try again
  107.        
  108.        
  109.         // print out a message asking if they want to continue, print q to quit)
  110.        
  111.         // get the input from the user
  112.        
  113.         // in the while portion of the do loop, put while !answer.equals("q");
  114.         }while(!answer.equals("q"));
  115.                
  116.         // if outside the do loop, print out a summary of the wins and losses
  117.        
  118.         // call the toString of the LiarsDice class
  119.        
  120.     }
  121.    
  122.     // this method shows the current dice
  123.     public static void showCurrentDice()
  124.     {
  125.         // print out a message that shows the dice, by calling the getCurrentDice method of the LiarsDice class
  126.        
  127.     }
  128.    
  129.     // this methods just allows the user to make a claim
  130.     public static void makeClaim()
  131.     {
  132.         // print out a message asking for their claim
  133.        
  134.         // create an instance of the Scanner class
  135.        
  136.         // get the user's answer
  137.        
  138.         // print out the user's claim
  139.        
  140.     }
  141.    
  142.     // this method should print out the menu of choices
  143.     public static void showMenu()
  144.     {
  145.         // print out a message that asks what they want to do
  146.        
  147.         // print out a message asking if they want to make a claim: 1. Make a claim
  148.        
  149.         // print out a message asking if they want to roll again
  150.        
  151.         // print out a message asking if they want to save their dice
  152.        
  153.         // print out a messgae that asking if they want to show their dice
  154.        
  155.         // print out a message that asking if they want to increase their wins or losses
  156.        
  157.         // print out a message asking if they want to see the summary
  158.        
  159.         // print out a message asking if they want to play a new game
  160.        
  161.        
  162.     }
  163.    
  164.     // this method allows the user to save certain dice
  165.     public static void saveDice()
  166.     {
  167.         // create an instance of the Scanner class
  168.        
  169.         //print out a message asking which dice they want to save separated by commas (and no spaces)
  170.        
  171.         // get the dice entered and store it into a string called dice
  172.        
  173.         // send the String into another Scanner instance
  174.         Scanner myLineScan = new Scanner(dice);
  175.         // delimit the string with a comma
  176.         myLineScan.useDelimiter(",");
  177.         // check to see if there are tokens in the string
  178.         while(myLineScan.hasNext())
  179.         {
  180.             // make a call to the saveWhichDice for each integer in the string
  181.             myDice.saveWhichDice(myLineScan.nextInt());
  182.         }
  183.            
  184.     }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment