View Single Post
Old Nov 27th, 2005, 9:33 PM   #11
robrosas
Newbie
 
robrosas's Avatar
 
Join Date: Nov 2005
Location: Puerto Rico
Posts: 12
Rep Power: 0 robrosas is an unknown quantity at this point
Here's the code...

This is in a PairOfDice class
public class PairOfDice{
   int first_dice;
   int second_dice;
   int sides=6;
    public PairOfDice(){
    first_dice=0;
    second_dice=0;
    }
    

   


public void roll(){
    first_dice=(int) (Math.random()*sides) + 1;
    second_dice=(int) (Math.random()*sides) + 1;
}


}

And this is in a BoxCars class

  public class BoxCars {
    
    
  public static void main (String[] args){
      int counter=0;
     PairOfDice GameDices= new PairOfDice();
     for(int i=0;i<1000;i++){
        GameDices.roll();
        if((GameDices.first_dice==6)&&(GameDices.second_dice==6)){
        counter++;
        }
      
     }
     System.out.println("The result of cars is :"+counter);   
  }
    
}


Check out is that if what you need.
__________________
From P.R. to the World!! RoBeRt
robrosas is offline   Reply With Quote