flyingsheep
Technical User
i'm sorry i have to post this, but i havent been able to figure it out and i have a big project due tomorrow for computer science, what this is is a really bloated tic tac toe applet, for now, all i am looking for is 1. why it only fills the first square i select (from the JOptionPane), any other feedback about the game is welcome, sorry its not such an intelligent snippet, but its the best i can do at the moment.
thanks in advance,
alex
CODE:
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.awt.Rectangle;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.awt.font.FontRenderContext;
import java.awt.Color;
public class Chart extends Applet
{
public void paint(Graphics g)
{
Graphics2D g2=(Graphics2D)g;
Graphics2D g3=(Graphics2D)g;
Graphics2D g4=(Graphics2D)g;
Graphics2D g5=(Graphics2D)g;
Graphics2D g6=(Graphics2D)g;
Graphics2D g7=(Graphics2D)g;
Graphics2D g8=(Graphics2D)g;
Graphics2D g9=(Graphics2D)g;
Graphics2D g10=(Graphics2D)g;
Graphics2D g11=(Graphics2D)g;
Graphics2D g12=(Graphics2D)g;
Rectangle box1=new Rectangle(70,100,50,50);
g2.draw(box1);
Rectangle box2=new Rectangle(120,100,50,50);
g3.draw(box2);
Rectangle box3=new Rectangle(170,100,50,50);
g4.draw(box3);
Rectangle box4=new Rectangle(70,150,50,50);
g5.draw(box4);
Rectangle box5=new Rectangle(70,150,100,50);
g6.draw(box5);
Rectangle box6=new Rectangle(70,150,150,50);
g7.draw(box6);
Rectangle box7=new Rectangle(70,200,50,50);
g8.draw(box7);
Rectangle box8=new Rectangle(70,200,100,50);
g9.draw(box8);
Rectangle box9=new Rectangle(70,200,150,50);
g10.draw(box9);
g2.drawString("1", 90,130);
g2.drawString("2", 140,130);
g2.drawString("3", 190,130);
g2.drawString("4", 90,180);
g2.drawString("5", 140,180);
g2.drawString("6", 190,180);
g2.drawString("7", 90,230);
g2.drawString("8", 140,230);
g2.drawString("9", 190,230);
int moveNum=0;
String boxNum="0";
String color="red";
boxNum=JOptionPane.showInputDialog("input box number player");
int box1Istaken=0,box2Istaken=0,box3Istaken=0,box4Istaken=0,box5Istaken=0,box6Istaken=0,box7Istaken=0,box8Istaken=0,box9Istaken=0;
if(boxNum.equals("1"))
{
if(box1Istaken==0)
{
System.out.println("cool");
box1Istaken=1;
moveNum+=1;
g2.fill(box1);
g2.draw(box1);
}
}
if(boxNum.equals("2"))
{
if(box2Istaken==0)
{
System.out.println("cool");
box2Istaken=1;
moveNum+=1;
g3.fill(box2);
}
}
if(boxNum.equals("3"))
{
if(box3Istaken==0)
{
System.out.println("cool");
box3Istaken=1;
moveNum+=1;
g4.fill(box3);
}
}
if(boxNum.equals("4"))
{
if(box4Istaken==0)
{
System.out.println("cool");
box4Istaken=1;
moveNum+=1;
g5.fill(box4);
}
}
if(boxNum.equals("5"))
{
if(box5Istaken==0)
{
System.out.println("cool");
box5Istaken=1;
moveNum+=1;
g6.fill(box5);
}
}
if(boxNum.equals("6"))
{
if(box6Istaken==0)
{
System.out.println("cool");
box6Istaken=1;
moveNum+=1;
g7.fill(box6);
}
}
if(boxNum.equals("7"))
{
if(box7Istaken==0)
{
System.out.println("cool");
box7Istaken=1;
moveNum+=1;
g8.fill(box7);
}
}
if(boxNum.equals("8"))
{
if(box8Istaken==0)
{
System.out.println("cool");
box8Istaken=1;
moveNum+=1;
g9.fill(box8);
}
}
if(boxNum.equals("9"))
{
if(box9Istaken==0)
{
System.out.println("cool");
box9Istaken=1;
moveNum+=1;
g10.fill(box9);
}
}
if(moveNum==9)
{
g2.setColor(Color.red);
g2.drawString("SomeOne Wins", 140,180);
}
}
}
thanks in advance,
alex
CODE:
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.awt.Rectangle;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.awt.font.FontRenderContext;
import java.awt.Color;
public class Chart extends Applet
{
public void paint(Graphics g)
{
Graphics2D g2=(Graphics2D)g;
Graphics2D g3=(Graphics2D)g;
Graphics2D g4=(Graphics2D)g;
Graphics2D g5=(Graphics2D)g;
Graphics2D g6=(Graphics2D)g;
Graphics2D g7=(Graphics2D)g;
Graphics2D g8=(Graphics2D)g;
Graphics2D g9=(Graphics2D)g;
Graphics2D g10=(Graphics2D)g;
Graphics2D g11=(Graphics2D)g;
Graphics2D g12=(Graphics2D)g;
Rectangle box1=new Rectangle(70,100,50,50);
g2.draw(box1);
Rectangle box2=new Rectangle(120,100,50,50);
g3.draw(box2);
Rectangle box3=new Rectangle(170,100,50,50);
g4.draw(box3);
Rectangle box4=new Rectangle(70,150,50,50);
g5.draw(box4);
Rectangle box5=new Rectangle(70,150,100,50);
g6.draw(box5);
Rectangle box6=new Rectangle(70,150,150,50);
g7.draw(box6);
Rectangle box7=new Rectangle(70,200,50,50);
g8.draw(box7);
Rectangle box8=new Rectangle(70,200,100,50);
g9.draw(box8);
Rectangle box9=new Rectangle(70,200,150,50);
g10.draw(box9);
g2.drawString("1", 90,130);
g2.drawString("2", 140,130);
g2.drawString("3", 190,130);
g2.drawString("4", 90,180);
g2.drawString("5", 140,180);
g2.drawString("6", 190,180);
g2.drawString("7", 90,230);
g2.drawString("8", 140,230);
g2.drawString("9", 190,230);
int moveNum=0;
String boxNum="0";
String color="red";
boxNum=JOptionPane.showInputDialog("input box number player");
int box1Istaken=0,box2Istaken=0,box3Istaken=0,box4Istaken=0,box5Istaken=0,box6Istaken=0,box7Istaken=0,box8Istaken=0,box9Istaken=0;
if(boxNum.equals("1"))
{
if(box1Istaken==0)
{
System.out.println("cool");
box1Istaken=1;
moveNum+=1;
g2.fill(box1);
g2.draw(box1);
}
}
if(boxNum.equals("2"))
{
if(box2Istaken==0)
{
System.out.println("cool");
box2Istaken=1;
moveNum+=1;
g3.fill(box2);
}
}
if(boxNum.equals("3"))
{
if(box3Istaken==0)
{
System.out.println("cool");
box3Istaken=1;
moveNum+=1;
g4.fill(box3);
}
}
if(boxNum.equals("4"))
{
if(box4Istaken==0)
{
System.out.println("cool");
box4Istaken=1;
moveNum+=1;
g5.fill(box4);
}
}
if(boxNum.equals("5"))
{
if(box5Istaken==0)
{
System.out.println("cool");
box5Istaken=1;
moveNum+=1;
g6.fill(box5);
}
}
if(boxNum.equals("6"))
{
if(box6Istaken==0)
{
System.out.println("cool");
box6Istaken=1;
moveNum+=1;
g7.fill(box6);
}
}
if(boxNum.equals("7"))
{
if(box7Istaken==0)
{
System.out.println("cool");
box7Istaken=1;
moveNum+=1;
g8.fill(box7);
}
}
if(boxNum.equals("8"))
{
if(box8Istaken==0)
{
System.out.println("cool");
box8Istaken=1;
moveNum+=1;
g9.fill(box8);
}
}
if(boxNum.equals("9"))
{
if(box9Istaken==0)
{
System.out.println("cool");
box9Istaken=1;
moveNum+=1;
g10.fill(box9);
}
}
if(moveNum==9)
{
g2.setColor(Color.red);
g2.drawString("SomeOne Wins", 140,180);
}
}
}