codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Problem with Get and Set Methods  gosi at 08:28 on Thursday, November 03, 2005
 

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);

}
}


  Re: Problem with Get and Set Methods  crwood at 20:16 on Thursday, November 03, 2005
 


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 + "]";
}
}


  Re: Problem with Get and Set Methods  dabora at 06:04 on Thursday, April 28, 2011
 

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


  Re: Problem with Get and Set Methods  benben at 05:58 on Saturday, May 21, 2011
 


Fake Tag Heuer Monaco Chronograph White dial SS bracelet Watches online
Fake Tag Heuer Monaco Chronograph White dial leather band Watches online
Fake TAG Heuer Men's CAW2111.FC618 Monaco Calibre 12 Automatic Watches Watches online
Fake Tag Heuer Monza Calibre 36 White Dial Black Leather Strap Watches online
Fake Tag Heuer Monza Calibre 36 Black dial SS band Watches online
Fake Tag Heuer Monza Calibre 36 White Dial Leather band Watches online
Fake Tag Heuer Monaco Chronograph Black dial leather band Watches online
Fake Tag Heuer Monza Calibre 36 Black Dial Leather band Watches online
Fake Tag Heuer Professional Golf Watch White dial II Watches online
Fake Tag Heuer NBA Star Yao Ming Limited Edition White Dial Watches online

  Re: Problem with Get and Set Methods  wwwkan123 at 05:56 on Friday, June 24, 2011
 



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


  nice  danaray79 at 18:21 on Tuesday, August 02, 2011
 

I must appreciate you for the information you have shared.I find this information very useful and it has considerably saved my time.thanks

Buy Articles | Life Experience Degree | bachelor degree | Sample Essays

  Re: Problem with Get and Set Methods  liujunchina at 06:37 on Tuesday, August 30, 2011
 


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

  Re: Problem with Get and Set Methods  kllkk at 08:49 on Thursday, September 01, 2011
 

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]








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Billige Nike Sko
•  Billige Nike Sko
•  Billige Nike Sko
•  Billige Nike Sko
•  Billige Nike Sko
•  Billige Nike Sko
•  Billige Nike Sko
•  Billige Nike Sko
•  Billige Nike Sko


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2011