Penny pitch #2 The penny pitch game is poplar in amusement parks. Penniestossed
ID: 3610037 • Letter: P
Question
Penny pitch #2
The penny pitch game is poplar in amusement parks. Penniestossed onto a board that has certain areas marked with differentprizes. For example:
Puzzle
Poster
Doll
Poster
Doll
Ball
Puzzle
Game
Puzzle
Ball
Poster
Game
Doll
Game
Ball
The prizes available on this board are puzzle, ball,poster, and doll. You can change or use these prizes. At the end of the game, if all the squares that say Ball in themare covered by a penny, then the player gets a Ball. This isalso true of the other prizes. The board is made up of 25squares. Each prize appears on 3 randomly chosen squares sothat 15 squares contain prizes.Write a penny pitch program thatsimulates ten pennies being randomly pitched onto the board. At the end of the game display a list of prizes won or None.
JOptionPane everything including the board
Also If you landed on the a spot cover up with an XX. NO Numbersjust show what you won at the end of the program or if you did win.
Good looking output counts!!!!!!
Must use a double subscripted array and Square class.
Use an array of String to store the prizes.
Use an array of integer to store tosses of pennies.
There is no need for the lines between the 25 Boxes.
Maybe try to use this as your Square class:
public class Square extends Object{
private int number;
private boolean pennyLanded;
public Square(int n){
number = n;
pennyLanded = false;
}
public boolean pennyLanded(){
return pennyLanded;
}
public void setPennyLanded(){
pennyLanded = true;
}
public int getNumber(){
return number;
}
public void setNumber(int x)
{
number = x;
}
public String toString(){
if (pennyLanded)
return "P";
else
{
String temp="";
switch(number){
case 0: temp = " xx ";
break;
case 1: temp = " Poster ";
break;
case 2: temp = " Ball ";
break;
case 3: temp = " Game ";
break;
case 4: temp = " Puzzle ";
break;
case 5: temp = " Doll ";
}
return temp;}
}
}
Puzzle
Poster
Doll
Poster
Doll
Ball
Puzzle
Game
Puzzle
Ball
Poster
Game
Doll
Game
Ball
Explanation / Answer
Please rate - again Ask your Professor about "Scope Creep" and the Software DevelopmentLife Cycle. This is it. See what you can do with adding X'sas they are thrown import java.util.*; import javax.swing.*; public class pennypitch { public static void main(String []args) {Stringblank=" ",input; String[]x={" X "," XX "," XXX "}; String str=""; String[][] mat=new String[5][5]; String[]prize={"Puzzle ","Doll ","Game ","Poster ","Ball "}; int[][] count=new int[5][5]; int i,j,row,col ,tot,prizes; int location[][][]=new int[5][3][2]; String yorn="Y"; boolean done; while(yorn.charAt(0)=='Y'||yorn.charAt(0)=='y') {str=""; for (i=0;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.