I am running program through JGrasp and it compiles but the run stalls would someone mind telling me what is wrong?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.util.Random;
public class PennyPitch
{
public static void main(String[] args)
{
int score = 0;
int played = 0;
while(true){
int rows = 0;
int cols = 0;
int sum = 0;
int x = 0;
int points = 0;
int round = 0;
int total = 0;
int trials = 0;
boolean replay = true;
Random penny = new Random();
String str = " ";
Square2[][] table = new Square2[5][5];
String board = " ";
for(x =0; x < 5; x++){
table[0][x] = new Square2(1);
table[4][x] = new Square2(1);
table[x][0] = new Square2(1);
table[x][4] = new Square2(1);
}
for(x = 1; x < 4; x++){
table[1][x] = new Square2(2);
table[3][x] = new Square2(2);
table[x][1] = new Square2(2);
table[x][3] = new Square2(2);
}
table[2][2] = new Square2(3);
for(int x2 = 0; x2 < table.length; x2++){
for(int y2 = 0; y2 < table.length; y2++){
board += table[x2][y2] + " ";
}
board += "\n";
}
while(replay && round < 5)
{
int random = penny.nextInt(25) + 1;
trials = penny.nextInt(25) + 1;
rows = (trials - 1) / 5;
cols = (trials - 1) % 5;
str = "";
}
JOptionPane.showMessageDialog(null, "The Board:\n " + board);
points += table[rows][cols].getPoints();
table[rows][cols].setPennyLanded();
round++;
total++;
for(int rows2 = 0; rows2 < table.length; rows2++)
{
for(int cols2 = 0; cols2 < table.length; cols2++)
{
str += table[rows2][cols2] + " ";
}
str += "\n";
}
JOptionPane.showMessageDialog(null, "The Board: \t" + total + " out of 5 \n" + str);
score += points;
played++;
JOptionPane.showMessageDialog(null,"Score for this round is " + points + " points");
JOptionPane.showMessageDialog(null,"Total is " + score + " points");
int option = JOptionPane.showConfirmDialog(null, "Are you done yet?", "Select Option", JOptionPane.YES_NO_OPTION);
if (option == 0)
break;
}
JOptionPane.showMessageDialog(null, "Total Status: " + score + " points, in " + played + " rounds.");
}
}
sorry for bad english...