HELP NEEDED WITH THIS PROGRAM NEED BOTH PARTS AB DONE IN GOO
HELP NEEDED WITH THIS PROGRAM NEED BOTH PARTS A&B DONE IN GOOD JAVA PROGRAMMING STYLE. ASAP !!!
LAB ASSIGNMENT 1 Review of CSC162 Concepts Due: Thursday February 9th by 12:20pm (end of class) Submit each java file and .txt file electronically through Campus Cruiser by the due date. Submit a printout of your source code to the instructor by the due date 1. Write a class that simulates a standard pair of dice. You will later use this class to play the game of Craps. s is a table game which is played in casinos all over the world. Crap A. Create a class called Pat Dice. Objects of this class represent a single pair of six-sided dice a. The attributes of such an object are the face values of the two dice only b. Provide a constructor. di random number c. Provide a roll method that simulates rolling the Use the generator from Gaddis chapter 4 to get the value of each die d. Provide a method that returns the sum of the face values of the dice Provide a toString method that returns a nicely formatted string representing the e. value of each die and the sum of the pair, such as \"5 3 8\" the class works propcrly. (Your driver should test all class methods.) B. Play the game of Craps. basic bet made by the \"shooter\" in this game is the pass-line The bet a. To start a pass-line bet, the shooter makes a \"come-out\" roll. Roll the pair of dice b. If the \"come-out\" roll is a 2, 3, or 12 that is called \"craps\" or \"crapping out\" and the shooter immediately loses c. A \"come-out\" roll of 7 or 11 is a \"natural\" and the shooter immediately wins d. The other possible numbers are the point numbers: 4, 5, 6, 8, 9 and 10. If the shooter rolls one of these numbers on the come out roll, this establishes the \"point\". To win, the point number must be rolled again before a seven (7). So, in the case where a \"point\" is established the shooter rolls over and over until either the point is rolled (a win) or a seven (7) is rolled (a loss) 100 pass bets e. Using your Pai Dice class write an application that simulates running total of and output the results of each betto an output file. Also, keep a run how many wins and losses. Output those totals at the end of yourSolution
Driver.java
import java.io.PrintWriter;
import java.io.File;
public class Driver
{
public static void main(String[] args) throws Exception
{
PrintWriter writer = new PrintWriter(\"output.txt\", \"UTF-8\");
PairOfDice d = new PairOfDice();
int i = 0;
int wins = 0;
int loses = 0;
while(i<100)
{
writer.println(i+1);
d.Roll();
int mysum = d.summ();
if(mysum == 2 || mysum == 3 || mysum == 12)
{
writer.println(\"You Rolled \" + d.toString());
writer.println(\"You lose!\");
loses = loses + 1;
}
else if(mysum == 7 || mysum == 11)
{
writer.println(\"You Rolled \" + d.toString());
writer.println(\"You win!\");
wins = wins + 1;
}
else
{
writer.println(\"You Rolled \" + d.toString());
writer.println(\"Point is \" + mysum);
int point = mysum;
while(true)
{
d.Roll();
writer.println(\"You Rolled \" + d.toString());
mysum = d.summ();
if(mysum == point)
{
writer.println(\"You win!\");
wins = wins + 1;
break;
}
else if(mysum == 7)
{
writer.println(\"You lose!\");
loses = loses + 1;
break;
}
}
}
i =i + 1;
}
writer.println(\"Tatal wins = \" + wins);
writer.println(\"Tatal loses = \" + loses);
writer.close();
}
}
PairOfDice.java
public class PairOfDice
{
public int d1;
public int d2;
public PairOfDice() {
}
public void Roll()
{
this.d1 = (int )(Math.random() * 6 + 1);
this.d2 = (int )(Math.random() * 6 + 1);
}
public String toString()
{
String r;
r = this.d1 + \" + \" + this.d2 + \" = \" + (this.d1 + this.d2) ;
return r;
}
public int summ()
{
return (this.d1 + this.d2);
}
}

