The Artima Developer Community
Sponsored Link

Java Answers Forum
help with game

2 replies on 1 page. Most recent reply: Nov 3, 2003 6:31 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
federico

Posts: 1
Nickname: federico
Registered: Nov, 2003

help with game Posted: Nov 3, 2003 7:03 AM
Reply to this message Reply
Advertisement
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;
else sz = 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+1 0);
}
g.setColor(Color.black);
g.drawRect(9,9,sz*3+2,sz*3+2);

} //end of paitn method
}// end of class


David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: help with game Posted: Nov 3, 2003 2:08 PM
Reply to this message Reply
Do you know Java?

Yes? Then work it out yourself and then submit your analysis for discussion.

No? Learn Java first, then work it out yourself and then submit your analysis for discussion.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: help with game Posted: Nov 3, 2003 6:31 PM
Reply to this message Reply
It will look nicer and be easier to analyze if you use the java tags when posting, too.

Flat View: This topic has 2 replies on 1 page
Topic: making indexs based upon concatenated fields Previous Topic   Next Topic Topic: How load data from Mirosoft access and plot a graph

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use