Java Assignment - Dice Roll

Java class assignment, rolling of Dice

/*
 * Student Name: Joe Caulfield
 * Student Number: 20050493
 * Date: 2/2/2012
 * Purpose:
*/
public class DiceGame
{
    private Player1 player1;
    private FaceValue1 facevalue1;
   
    public DiceGame()
    {
        player1 = new Player1();
        facevalue1 = new FaceValue1();
    }
   
    public void play()
    {
        facevalue1.Roll();
       
        System.out.println("Well done you got: " + facevalue1.getDi1() );
    }
   
   
}

/*
 * Student Name: Joe Caulfield
 * Student Number: 20050493
 * Date: 2/2/2012
 * Purpose:
*/
public class FaceValue1
{
        private int Di1;   // Number showing on the first die.
        private int Di2;   // Number showing on the second die.
       
        public FaceValue1()  // Constructor. Rolls the dice.
        {
           
        }
       
        public void Roll()
// Roll the dice by setting each of the dice to be a random number between 1 and 6
        {
            Di1 = (int)(Math.random()*6) + 1; // Die1 given value using Math Class.
            Di2 = (int)(Math.random()*6) + 1; // Die2 given value using Math Class.
        }
       
        public int getTotal() // method to return total faceValue of Dice.
        {
           return Di1 + Di2;  // Return the total showing on the two dice.
        }
           
        public void setTotal()
        {
        }
       
        public int getDi1()
        {
            // Return the number showing on the first die.
           return Di1;
           
        }
       
        public void setDi1()
        {
        }
       
        public int getDi2()
        {
           // Return the number showing on the second die.
           return Di2;

        }
       
        public void setDi2()
        {
        }
       
}  // end of Dice Class

/*
 * Student Name: Joe Caulfield
 * Student Number: 20050493
 * Date: 2/2/2012
 * Purpose:
*/
import java.util.Scanner;

public class Player1
{
    public static void main(String args [])
    {
        Scanner keyboard = new Scanner(System.in);
       
        DiceGame G1 = new DiceGame();
       
        int Score1 = 0;
        int Score2 = 0;
        String Player1;
     
        G1.play();

       
    }
}
       


Comments

Popular Posts