Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The "SumDice1b" class.
- import java.awt.*;
- import hsa.Console;
- import usefulstuff.*;
- public class SumDice1b
- {
- static Console c; // The output console
- public static void main (String[] args)
- {
- c = new Console ();
- char key;
- Dice d1;
- d1 = new Dice (225, 200, 200, 1, Color.green);
- int total;
- total = 0;
- c.println ("Instructions:");
- c.println ("hit anykey to roll the dice and for the sum to be added");
- c.println ("hit q to see the sum and quit the program");
- do
- {
- d1.roll ();
- d1.draw (c);
- total = total + d1.getNumber ();
- key = c.getChar ();
- }
- while (key != 'q');
- int sum;
- sum = 0;
- c.println ("Enter sum:");
- sum = c.readInt ();
- while (sum < total || sum > total)
- {
- if (sum < total || sum > total)
- {
- c.println ("that is wrong.");
- sum = c.readInt ();
- }
- else if (sum == total)
- {
- c.println ("Right.");
- }
- }
- // Place your program here. 'c' is the output console
- } // main method
- } // SumDice1a class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement