import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import javax.swing.*;
import java.util.Arrays;
/**
* Write a description of class Square here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Square extends Actor
{
int index = 0;
static int [] squareValue = new int[81];
/**
* Act - do whatever the Square wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
placeNum();
newGame();
//checkNum();
//getWorld().showText(index + " ", getX(), getY());
}
public void placeNum(){
if(Greenfoot.mouseClicked(this)){
JFrame num;
num=new JFrame();
do{
squareValue[index] = Integer.parseInt(JOptionPane.showInputDialog(num,"What number?(1-9)"));
}while(squareValue[index] < 1 || squareValue[index] > 9);
getWorld().showText(squareValue[index] + "", getX(), getY());
}
}
public void checkNum(){
}
public void newGame(){
Button button = getWorld().getObjects(Button.class).get(0);
int difficulty = 0;
if (Greenfoot.mouseClicked(button)){
JFrame diff;
diff=new JFrame();
boolean diffSet = false;
if(diffSet == false){
diffSet = true;
do {
difficulty = Integer.parseInt(JOptionPane.showInputDialog(diff,"What Difficulty? (1-3)"));
if(difficulty < 1 || difficulty > 3){
break;
}
break;
}while(true);
}
if(difficulty == 1){
int easy = Greenfoot.getRandomNumber(10);
if(easy == 1){
getWorld().showText("7", getX(), getY());
}
else if(easy == 2){
getWorld().showText("2 works", 20, 20);
}
else if(easy == 3){
getWorld().showText("3 works", 20, 20);
}
else if(easy == 4){
getWorld().showText("4 works", 20, 20);
}
else if(easy == 5){
getWorld().showText("5 works", 20, 20);
}
else if(easy == 6){
getWorld().showText("6 works", 20, 20);
}
else if(easy == 7){
getWorld().showText("7 works", 20, 20);
}
else if(easy == 8){
getWorld().showText("8 works", 20, 20);
}
else if(easy == 9){
getWorld().showText("9 works", 20, 20);
}
else if(easy == 10){
getWorld().showText("10 works", 20, 20);
}
}
else if(difficulty == 2){
int med = Greenfoot.getRandomNumber(10);
if(med == 1){
}
else if(med == 2){
}
else if(med == 3){
}
else if(med == 4){
}
else if(med == 5){
}
else if(med == 6){
}
else if(med == 7){
}
else if(med == 8){
}
else if(med == 9){
}
else if(med == 10){
}
}
else if(difficulty == 3){
int hard = Greenfoot.getRandomNumber(10);
if(hard == 1){
}
else if(hard == 2){
}
else if(hard == 3){
}
else if(hard == 4){
}
else if(hard == 5){
}
else if(hard == 6){
}
else if(hard == 7){
}
else if(hard == 8){
}
else if(hard == 9){
}
else if(hard == 10){
}
}
}
}
}
