• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help with game

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could somebody give me a detailed explanation of how this tictactoe game program works?
thanks you. this is the code:
import javax.swing.*;
import java.awt.*;
import java.applet.*;
public class TicTac extends JApplet
{
public void init()
{
// declaration aand created array
int Array[] = new int[8];
String input1;
String input2;
int choice1 = 0;
int choice2;
for(int i=0; i < Array.length; i++) Array = 0;
while (choice1 == 0)
{
input1 = JOptionPane.showInputDialog
("Please select your symbol\n"+
"1= O \n"+
"2= X \n");
if (input1.equals("1")) choice1 = 1;
if (input1.equals("2")) choice1 = 2;
}
//converts string to integer
//choice1 = Integer.parseInt( input1 );
}
// draws the TicTacToe Board...
public void paint(Graphics g)
{
Dimension d = getSize();
g.setColor(Color.blue);
int sz = 0;
if (d.height/4 - 10 < d.width/4) sz = d.height / 4;
elsesz = d.width / 4;
for (int j=0; j < 4; j++)
{
g.drawLine(10,sz*j+10,sz*3+10,sz*j+10);
g.drawLine(j*sz+10,10,j*sz+10,sz*3+10);
}
g.setColor(Color.black);
g.drawRect(9,9,sz*3+2,sz*3+2);
} //end of paitn method
}// end of class
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by federico elbl:
could somebody give me a detailed explanation of how this tictactoe game program works?


I will bet it doesn't do much. Is this a class assignment?
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried to compile it?
It has some errors. Try to compile it and see what it does.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic