|
I have a project and it´s like this: "Design and implement an application that rolls a pair of dice 1000 times, counting the number of box cars(two sixes) that occur".
I´m quite sure that I have to use a for-statement to count the number of throws and then use if-statement to determine when I have two sixes, but because I´m working with get and set methods I don´t know where to put the different statements, so I would appreciate all help :D
here is my codes:
public class PairOf1000Dice
{
private final int MAX = 6; // maximum face value
private int FV1; // current value showing on die 1
private int FV2; //current value showing on die 2
public PairOf1000Dice()
{
FV1 = 0;
FV2 = 0;
}
public int roll_1()
{
FV1 = (int)(Math.random() * MAX) + 1;
return FV1;
}
public int roll_2()
{
FV2 = (int)(Math.random() * MAX) + 1;
return FV2;
}
public void setFaceValue1 (int value1)
{
FV1 = value1;
}
public void setFaceValue2(int value2)
{
FV2 = value2;
}
public int getFaceValue1()
{
return FV1;
}
public int getFaceValue2()
{
return FV2;
}
public String toString()
{
String result = Integer.toString(FV1+FV2);
return result;
}
}
-------------------------------------------------------------
public class Rolling1000Dice {
public static void main (String[] args)
{
PairOf1000Dice die1, die2;
int sum;
die1 = new PairOf1000Dice();
die2 = new PairOf1000Dice();
die1.roll_1();
die2.roll_2();
System.out.println ("Die One: " + die1 + ", Die Two: " + die2);
sum = die1.getFaceValue1() + die2.getFaceValue2();
System.out.println ("Sum: " + sum);
}
}
|
|
|
public class RollingTest
{
public static void main(String[] args)
{
Dice dice = new Dice();
int count = 0;
for(int j = 0; j < 10; j++)
{
dice.roll();
if(dice.getDie1() + dice.getDie2() == 12)
count++;
}
System.out.println("count = " + count);
}
}
class Dice
{
int maxValue = 6;
int die1, die2;
public Dice()
{
die1 = die2 = 0;
}
public void roll()
{
die1 = (int)(Math.random() * maxValue) + 1;
die2 = (int)(Math.random() * maxValue) + 1;
}
public int getDie1() { return die1; }
public int getDie2() { return die2; }
public String toString()
{
return "Dice[die1:" + die1 + ", die2:" + die2 + "]";
}
}
|
|
|
|
|
Every day, or so it seems, new research shows that some aspect of lifestyle - physical activity, diet, alcohol consumption, and so on - affects health and longevity. Physical fitness is good bodily health, and is the result of regular exercise, proper diet and nutrition, and proper rest for physical recovery. The field of nutrition also studies foods and dietary supplements that improve performance, promote health, and cure or prevent disease, such as fibrous foods to reduce the risk of colon cancer, or supplements with vitamin C to strengthen teeth and gums and to improve the immune system. When exercising, it becomes even more important to have a good diet to ensure that the body has the correct ratio of macronutrients whilst providing ample micronutrients; this is to aid the body in the recovery process following strenuous exercise.
__________________________________________________________
testking 000-979| testking E20-001| testking 70-516| testking 1z0-536| testking 640-863| testking 642-165| testking 70-648| testking 70-513| testking 350-029| testking 646-578
|
|
|
|
|
Today I found a wonderful website,the site contained:
wedding dresses
cheap wedding dresses
Junior Bridesmaid Dresses
Cheap Homecoming Dresses
Cheap Quinceanera Dresses
Inexpensive bridesmaid dresses
Wholesale wedding dress
Wholesale wedding dress
Discount wedding dresses
Cheap Maternity Wedding Dresses
A-Line Wedding Dresses
Cheap Couture Wedding Dresses
Cheap Beach Wedding Dresses
Cheap Casual Wedding Dresses
Cheap Simple Wedding Dresses
Cheap Modest Wedding Dresses
Cheap Special Occasion Dresses
Cheap Evening Dresses
Cheap Prom Dresses
Cheap Little Black Dresses
Cheap Plus Size Wedding Dresses
Pink Wedding Dresses
Cheap Wedding Party Dresses
Cheap Bridesmaid Dresses
Cheap Flower Girl Dresses
Cheap Mother of the Bride Dresses
victoria's secret,
cheap wedding dresses,wholesale wedding dress,Wedding dresses 2011,Plus Size Wedding Dress wholesale,Couture Wedding Dress wholesale,Formal Wedding Dress wholesale,Bridesmaid Dresses wholesale,Discount Bridesmaid Dress wholesale,Junior Bridesmaids Dresses wholesale,Maternity Bridesmaid Dress wholesale,Cocktail Dress wholesale,Prom Dress wholesale,Evening Dress wholesale,Sexy Evening Dress wholesale,Stardoll Dress wholesale,Quinceanera Dress wholesale,Mother of the Bride Dress,Flower Girl Dress,Wedding Accessories wholesale
|
|
|
|
|
oakley sunglasses,cheap oakley sunglasses,sale oakley sunglasses,oakley sunglasses sale,oakley sunglasses cheap oakley sunglasses on sale,sunglasses oakley,oakley sunglass,oakley glasses,oakley sunglasses discount designer sunglasses,discount sunglasses,wholesale sunglasses, oakley sunglasses online,Oakley Antix,Oakley Gascan,Oakley Hijinx,Oakley Jury,Oakley Monster Dog, Oakley Scapel,Oakley Straight Jacket,Oakley Active Sunglasses,Oakley Fives,Oakley Flak Jacket, Oakley Jawbone,Oakley Juliet,Oakley Life Sunglasses,Oakley M Frame,Oakley New Arrivals, Oakley New Popurzed,Oakley Oil Drum,Oakley Radar Path,Oakley Radar Range, Oakley Radar Xl Blades,Oakley Rig,Oakley Sideways,Oakley Sport Sunglasses. oakley sunglasses sku#32-275 oakley jawbone cheap,cheap oakley sunglasses for sale,oakley gascan cheap,cheap oakley radar path sunglasses cheap oakley jawbone,oakley sale,radar range sunglasses sale,
¡¡¡¡OAKLEY ANTIX,OAKLEY GASCAN,OAKLEY HIJINX,OAKLEY JURY,OAKLEY MONSTER DOG,OAKLEY SCAPEL,OAKLEY STRAIGHT JACKET,Oakley Active Sunglasses,OAKLEY FIVES,OAKLEY FLAK JACKET,OAKLEY JAWBONE,OAKLEY JULIET,Oakley Life Sunglasses,OAKLEY M FRAME,OAKLEY OIL DRUM,OAKLEY RADAR PATH,OAKLEY RADAR RANGE,OAKLEY RADAR XL BLADES,OAKLEY RIG,OAKLEY SIDEWAYS,Oakley Sport Sunglasses
|
|
|
Professional Coach Outlet Online service for you! Whether you like modern design Coach or classci Coach, your¡¯re in luck! Our Coach Outlet Store Online carries a large selection of your favorite. Here you will there are lots of series On Sale, including Coach Bags Outlet Series, Coach Shoes Series, Cheap Coach Purses Outlet Series, Coach Sunglasses Series. Each series also have many kinds of different styles can be choosen and purchased[/url].As one of the famous Coach Outlet Stores Online, we have won a good reputation in the market, and owing we have been engaged in Coach Bags Online Sale for some years, our Coach Bags have many loyal customers,the sales in the market is also good. [/url]To make customer satisfy is our aim, choose our Coach Factory Outlet, we will not let you down![/p]
|
|
|
|
|
|
|
|