View Single Post
Old Nov 27th, 2005, 7:34 PM   #10
ps2cho
Newbie
 
Join Date: Nov 2005
Posts: 2
Rep Power: 0 ps2cho is on a distinguished road
//***********************************************************************
// xxxxx			Project 4-4						11/26/05
// Design and implement a class called PairOfDice, with two six-sided
// Die objects. Create a driver class called BoxCars with a main method
// that rolls a PairOfDice object 1000 time, counting the number of box
// cars (two sixes) that occur.
//***********************************************************************

import cs1.Keyboard;
import java.util.Random;
import java.lang.Math;

public class P4_4 
{
	
	
	// Creates the 2 die objects
    class PairOfDice
    {
    	int sides = 6;
    	PairOfDice Dice1 = new PairOfDice(sides);
		PairOfDice Dice2 = new PairOfDice(sides);
    }
    
    // rolls the dice.
	public void roll() 
	{
		DiceRoll = (int) (Math.random()*sides) + 1;
        
    }
    
    class BoxCars
    {
    	public static void main(String[] args) 
    		{
 
				
				int result1=0,resullt2=0;
				int count = 0;
				
				
				for (int i=0;i<1000;i++)
				{
					result1=Dice1.roll();
					result2=Dice2.roll();
					
					if(result1=6 && result2=6)
						count++;
				}
				System.out.println("The total number of double sixes are: "+count);
			}
    
	}
}

Ok thats what i have now. Im so confused. I used your code above, but it only asks for when two 6's are rolled.
these are the errors i'm getting:

cannot resolve symbol
symbol  : constructor PairOfDice (int)

cannot resolve symbol
symbol  : variable DiceRoll 

cannot resolve symbol
symbol  : variable sides 

cannot resolve symbol
symbol  : variable Dice1 

cannot resolve symbol
symbol  : variable result2 

cannot resolve symbol
symbol  : variable Dice2 

incompatible types
found   : int
required: boolean
                                        if(result1=6 && result2=6)
                                           ^
cannot resolve symbol
symbol  : variable result2 
                                        if(result1=6 && result2=6)
                                                        ^
inner classes cannot have static declarations
        public static void main(String[] args) 
                           ^
10 errors

Process completed.

Im about to just give up as im completely fried. I dont understand this and its so frustrating.
ps2cho is offline   Reply With Quote