how will i repeat my whole game program?

Reply

Join Date: Sep 2004
Posts: 18
Reputation: psylocke is an unknown quantity at this point 
Solved Threads: 0
psylocke psylocke is offline Offline
Newbie Poster

how will i repeat my whole game program?

 
0
  #1
Sep 14th, 2004
here is my program and hope u could help me solve my problem on how to repeat this whole game program when the player chooses the the Yes button which indicates that he'd like to play again.

  1. a:\master1.java
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 153
Reputation: cosi is an unknown quantity at this point 
Solved Threads: 1
cosi's Avatar
cosi cosi is offline Offline
Junior Poster

Re: how will i repeat my whole game program?

 
0
  #2
Sep 14th, 2004
I don't see any code... and try to make some headway into the problem yourself... it's bad to simply ask on these forums for homework answers. Try to learn something.

Originally Posted by psylocke
here is my program and hope u could help me solve my problem on how to repeat this whole game program when the player chooses the the Yes button which indicates that he'd like to play again.

  1. a:\master1.java
In a world without walls or fences,
What use are Windows and Gates.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: how will i repeat my whole game program?

 
0
  #3
Sep 14th, 2004
you know cosi is so helping .. . always positive....
Reply With Quote Quick reply to this message  
Join Date: May 2003
Posts: 307
Reputation: big_k105 is an unknown quantity at this point 
Solved Threads: 2
Team Colleague
big_k105's Avatar
big_k105 big_k105 is offline Offline
PFO Founder

Re: how will i repeat my whole game program?

 
0
  #4
Sep 14th, 2004
post your code so we can see what you have and help you out
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 18
Reputation: psylocke is an unknown quantity at this point 
Solved Threads: 0
psylocke psylocke is offline Offline
Newbie Poster

Re: how will i repeat my whole game program?

 
0
  #5
Sep 16th, 2004
sorry guys, here is my code:

import java.awt.*;
import java.lang.Math;
import java.applet.Applet;
import javax.swing.*;
import java.awt.event.*;


public class mastermind extends Applet implements ActionListener
{

int tri=0,put=1,set=1,t,in=0,w,n,ctr=0,c=0,x,win=0,lose=0,pasaloadcp=0,pasaloadset=0;
int [] secretCol;
int tapos[]={-1,-1,-1};
int pickCol[];
int copyy[];

Label peglbl1=new Label("");
Label peglbl2=new Label("");
Label peglbl3=new Label("");
Label peglbl4=new Label("");
Label peglbl5=new Label("");
Label peglbl6=new Label("");
Label peglbl7=new Label("");
Label peglbl8=new Label("");
Label peglbl9=new Label("");
Label peglbl10=new Label("");
Label peglbl11=new Label("");
Label peglbl12=new Label("");
Label peglbl13=new Label("");
Label peglbl14=new Label("");
Label peglbl15=new Label("");
Button colbtn1=new Button();
Button colbtn2=new Button();
Button colbtn3=new Button();
Button colbtn4=new Button();
Button colbtn5=new Button();
Button colbtn6=new Button();
Label gnolbl1=new Label("Guess #1");
Label gnolbl2=new Label("Guess #2");
Label gnolbl3=new Label("Guess #3");
Label gnolbl4=new Label("Guess #4");
Label gnolbl5=new Label("Guess #5");
Label winlbl=new Label("WIN");
Label loselbl=new Label("LOSE");
Label clulbl1=new Label("");
Label clulbl2=new Label("");
Label clulbl3=new Label("");
Label clulbl4=new Label("");
Label clulbl5=new Label("");
Label clulbl6=new Label("");
Label clulbl7=new Label("");
Label clulbl8=new Label("");
Label clulbl9=new Label("");
Label clulbl10=new Label("");
Label clulbl12=new Label("");


Label blbl2=new Label("");
Label blbl4=new Label("");

Label slbl2=new Label("");
Label slbl3=new Label("");
Label slbl4=new Label("");

Label sclbl1=new Label("0");
Label sclbl2=new Label("0");

public void init()
{

pickCol=new int[3];
tapos=new int[3];
copyy=new int[3];

setLayout(new GridLayout(8,6,5,5));
colbtn1.addActionListener(this);
colbtn2.addActionListener(this);
colbtn3.addActionListener(this);
colbtn4.addActionListener(this);
colbtn5.addActionListener(this);
colbtn6.addActionListener(this);

add(gnolbl1);
add(peglbl1);
add(peglbl2);
add(peglbl3);
add(clulbl1);
add(clulbl2);

add(gnolbl2);
add(peglbl4);
add(peglbl5);
add(peglbl6);
add(clulbl3);
add(clulbl4);

add(gnolbl3);
add(peglbl7);
add(peglbl8);
add(peglbl9);
add(clulbl5);
add(clulbl6);

add(gnolbl4);
add(peglbl10);
add(peglbl11);
add(peglbl12);
add(clulbl7);
add(clulbl8);

add(gnolbl5);
add(peglbl13);
add(peglbl14);
add(peglbl15);
add(clulbl9);
add(clulbl10);

add(colbtn1);
add(colbtn2);
add(colbtn3);
add(colbtn4);
add(colbtn5);
add(colbtn6);

peglbl1.setBackground(Color.DARK_GRAY);
peglbl2.setBackground(Color.DARK_GRAY);
peglbl3.setBackground(Color.DARK_GRAY);
peglbl4.setBackground(Color.DARK_GRAY);
peglbl5.setBackground(Color.DARK_GRAY);
peglbl6.setBackground(Color.DARK_GRAY);
peglbl7.setBackground(Color.DARK_GRAY);
peglbl8.setBackground(Color.DARK_GRAY);
peglbl9.setBackground(Color.DARK_GRAY);
peglbl10.setBackground(Color.DARK_GRAY);
peglbl11.setBackground(Color.DARK_GRAY);
peglbl12.setBackground(Color.DARK_GRAY);
peglbl13.setBackground(Color.DARK_GRAY);
peglbl14.setBackground(Color.DARK_GRAY);
peglbl15.setBackground(Color.DARK_GRAY);

gnolbl1.setBackground(Color.LIGHT_GRAY);
gnolbl2.setBackground(Color.LIGHT_GRAY);
gnolbl3.setBackground(Color.LIGHT_GRAY);
gnolbl4.setBackground(Color.LIGHT_GRAY);
gnolbl5.setBackground(Color.LIGHT_GRAY);

clulbl1.setBackground(Color.LIGHT_GRAY);
clulbl2.setBackground(Color.LIGHT_GRAY);
clulbl3.setBackground(Color.LIGHT_GRAY);
clulbl4.setBackground(Color.LIGHT_GRAY);
clulbl5.setBackground(Color.LIGHT_GRAY);
clulbl6.setBackground(Color.LIGHT_GRAY);
clulbl7.setBackground(Color.LIGHT_GRAY);
clulbl8.setBackground(Color.LIGHT_GRAY);
clulbl9.setBackground(Color.LIGHT_GRAY);
clulbl10.setBackground(Color.LIGHT_GRAY);

colbtn1.setLabel("Green");
colbtn2.setLabel("Blue");
colbtn3.setLabel("Red");
colbtn4.setLabel("Yellow");
colbtn5.setLabel("Orange");
colbtn6.setLabel("Magenta");
colbtn1.setBackground(Color.GREEN);
colbtn2.setBackground(Color.BLUE);
colbtn3.setBackground(Color.RED);
colbtn4.setBackground(Color.YELLOW);
colbtn5.setBackground(Color.ORANGE);
colbtn6.setBackground(Color.MAGENTA);


add(winlbl);
add(sclbl1);
add(blbl2);
add(loselbl);
add(sclbl2);
add(blbl4);


add(slbl2);
add(slbl3);
add(slbl4);

}//init

public void start()
{
double m;
int k,a;
secretCol=new int[3];
for(a=0;a<3;a++)
{
secretCol[a]=-1;
while(secretCol[a]<0)
{
m=Math.random();
k=(int) Math.floor((m*6)+1);
secretCol[a]=k;
}
}

for(a=0;a<3;a++)
{
if(a==0)
{
if(secretCol[a]==1)
slbl2.setBackground(Color.GREEN);
else if(secretCol[a]==2)
slbl2.setBackground(Color.BLUE);
else if(secretCol[a]==3)
slbl2.setBackground(Color.RED);
else if(secretCol[a]==4)
slbl2.setBackground(Color.YELLOW);
else if(secretCol[a]==5)
slbl2.setBackground(Color.ORANGE);
else if(secretCol[a]==6)
slbl2.setBackground(Color.MAGENTA);
}
else if(a==1)
{
if(secretCol[a]==1)
slbl3.setBackground(Color.GREEN);
else if(secretCol[a]==2)
slbl3.setBackground(Color.BLUE);
else if(secretCol[a]==3)
slbl3.setBackground(Color.RED);
else if(secretCol[a]==4)
slbl3.setBackground(Color.YELLOW);
else if(secretCol[a]==5)
slbl3.setBackground(Color.ORANGE);
else if(secretCol[a]==6)
slbl3.setBackground(Color.MAGENTA);
}
else if(a==2)
{
if(secretCol[a]==1)
slbl4.setBackground(Color.GREEN);
else if(secretCol[a]==2)
slbl4.setBackground(Color.BLUE);
else if(secretCol[a]==3)
slbl4.setBackground(Color.RED);
else if(secretCol[a]==4)
slbl4.setBackground(Color.YELLOW);
else if(secretCol[a]==5)
slbl4.setBackground(Color.ORANGE);
else if(secretCol[a]==6)
slbl4.setBackground(Color.MAGENTA);
}
}
}//clrBoard

public void actionPerformed(ActionEvent ae)
{

int rightcp=0,rightcol=0;
int what=0;

tri++;
if(ae.getSource()==colbtn1)
{
if(tri==1)
peglbl1.setBackground(Color.GREEN);
else if(tri==2)
peglbl2.setBackground(Color.GREEN);
else if(tri==3)
peglbl3.setBackground(Color.GREEN);
else if(tri==4)
peglbl4.setBackground(Color.GREEN);
else if(tri==5)
peglbl5.setBackground(Color.GREEN);
else if(tri==6)
peglbl6.setBackground(Color.GREEN);
else if(tri==7)
peglbl7.setBackground(Color.GREEN);
else if(tri==8)
peglbl8.setBackground(Color.GREEN);
else if(tri==9)
peglbl9.setBackground(Color.GREEN);
else if(tri==10)
peglbl10.setBackground(Color.GREEN);
else if(tri==11)
peglbl11.setBackground(Color.GREEN);
else if(tri==12)
peglbl12.setBackground(Color.GREEN);
else if(tri==13)
peglbl13.setBackground(Color.GREEN);
else if(tri==14)
peglbl14.setBackground(Color.GREEN);
else if(tri==15)
peglbl15.setBackground(Color.GREEN);
what=1;
}
else if(ae.getSource()==colbtn2)
{

if(tri==1)
peglbl1.setBackground(Color.BLUE);
else if(tri==2)
peglbl2.setBackground(Color.BLUE);
else if(tri==3)
peglbl3.setBackground(Color.BLUE);
else if(tri==4)
peglbl4.setBackground(Color.BLUE);
else if(tri==5)
peglbl5.setBackground(Color.BLUE);
else if(tri==6)
peglbl6.setBackground(Color.BLUE);
else if(tri==7)
peglbl7.setBackground(Color.BLUE);
else if(tri==8)
peglbl8.setBackground(Color.BLUE);
else if(tri==9)
peglbl9.setBackground(Color.BLUE);
else if(tri==10)
peglbl10.setBackground(Color.BLUE);
else if(tri==11)
peglbl11.setBackground(Color.BLUE);
else if(tri==12)
peglbl12.setBackground(Color.BLUE);
else if(tri==13)
peglbl13.setBackground(Color.BLUE);
else if(tri==14)
peglbl14.setBackground(Color.BLUE);
else if(tri==15)
peglbl15.setBackground(Color.BLUE);
what=2;
}
else if(ae.getSource()==colbtn3)
{
if(tri==1)
peglbl1.setBackground(Color.RED);
else if(tri==2)
peglbl2.setBackground(Color.RED);
else if(tri==3)
peglbl3.setBackground(Color.RED);
else if(tri==4)
peglbl4.setBackground(Color.RED);
else if(tri==5)
peglbl5.setBackground(Color.RED);
else if(tri==6)
peglbl6.setBackground(Color.RED);
else if(tri==7)
peglbl7.setBackground(Color.RED);
else if(tri==8)
peglbl8.setBackground(Color.RED);
else if(tri==9)
peglbl9.setBackground(Color.RED);
else if(tri==10)
peglbl10.setBackground(Color.RED);
else if(tri==11)
peglbl11.setBackground(Color.RED);
else if(tri==12)
peglbl12.setBackground(Color.RED);
else if(tri==13)
peglbl13.setBackground(Color.RED);
else if(tri==14)
peglbl14.setBackground(Color.RED);
else if(tri==15)
peglbl15.setBackground(Color.RED);
what=3;
}
else if(ae.getSource()==colbtn4)
{
if(tri==1)
peglbl1.setBackground(Color.YELLOW);
else if(tri==2)
peglbl2.setBackground(Color.YELLOW);
else if(tri==3)
peglbl3.setBackground(Color.YELLOW);
else if(tri==4)
peglbl4.setBackground(Color.YELLOW);
else if(tri==5)
peglbl5.setBackground(Color.YELLOW);
else if(tri==6)
peglbl6.setBackground(Color.YELLOW);
else if(tri==7)
peglbl7.setBackground(Color.YELLOW);
else if(tri==8)
peglbl8.setBackground(Color.YELLOW);
else if(tri==9)
peglbl9.setBackground(Color.YELLOW);
else if(tri==10)
peglbl10.setBackground(Color.YELLOW);
else if(tri==11)
peglbl11.setBackground(Color.YELLOW);
else if(tri==12)
peglbl12.setBackground(Color.YELLOW);
else if(tri==13)
peglbl13.setBackground(Color.YELLOW);
else if(tri==14)
peglbl14.setBackground(Color.YELLOW);
else if (tri==15)
peglbl15.setBackground(Color.YELLOW);
what=4;
}
else if(ae.getSource()==colbtn5)
{
if(tri==1)
peglbl1.setBackground(Color.ORANGE);
else if(tri==2)
peglbl2.setBackground(Color.ORANGE);
else if(tri==3)
peglbl3.setBackground(Color.ORANGE);
else if(tri==4)
peglbl4.setBackground(Color.ORANGE);
else if(tri==5)
peglbl5.setBackground(Color.ORANGE);
else if(tri==6)
peglbl6.setBackground(Color.ORANGE);
else if(tri==7)
peglbl7.setBackground(Color.ORANGE);
else if(tri==8)
peglbl8.setBackground(Color.ORANGE);
else if(tri==9)
peglbl9.setBackground(Color.ORANGE);
else if(tri==10)
peglbl10.setBackground(Color.ORANGE);
else if(tri==11)
peglbl11.setBackground(Color.ORANGE);
else if(tri==12)
peglbl12.setBackground(Color.ORANGE);
else if(tri==13)
peglbl13.setBackground(Color.ORANGE);
else if(tri==14)
peglbl14.setBackground(Color.ORANGE);
else if(tri==15)
peglbl15.setBackground(Color.ORANGE);
what=5;
}
else if(ae.getSource()==colbtn6)
{
if(tri==1)
peglbl1.setBackground(Color.MAGENTA);
else if(tri==2)
peglbl2.setBackground(Color.MAGENTA);
else if(tri==3)
peglbl3.setBackground(Color.MAGENTA);
else if(tri==4)
peglbl4.setBackground(Color.MAGENTA);
else if(tri==5)
peglbl5.setBackground(Color.MAGENTA);
else if(tri==6)
peglbl6.setBackground(Color.MAGENTA);
else if(tri==7)
peglbl7.setBackground(Color.MAGENTA);
else if(tri==8)
peglbl8.setBackground(Color.MAGENTA);
else if(tri==9)
peglbl9.setBackground(Color.MAGENTA);
else if(tri==10)
peglbl10.setBackground(Color.MAGENTA);
else if(tri==11)
peglbl11.setBackground(Color.MAGENTA);
else if(tri==12)
peglbl12.setBackground(Color.MAGENTA);
else if(tri==13)
peglbl13.setBackground(Color.MAGENTA);
else if(tri==14)
peglbl14.setBackground(Color.MAGENTA);
else if(tri==15)
peglbl15.setBackground(Color.MAGENTA);
what=6;
}

ctr=ctr+1;
pickCol[in++]=what;

if(ctr==3)
{

for(w=0;w<3;w++)
copyy[w]=secretCol[w];

for(w=0;w<3;w++)
{

if(pickCol[w]==secretCol[w])
{
rightcp=rightcp+1;
tapos[w]=pickCol[w];
}
}

for(w=0;w<3;w++)
for(x=0;x<3;x++)
if(pickCol[w]==tapos[w])
break;
else if(w==x)
continue;
else if(pickCol[w]==tapos[x])
continue;
else if(pickCol[w]==copyy[x])
{
rightcol=rightcol+1;
copyy[x]=-1;
break;
}


if(set==1)
{
if(rightcp==0)
clulbl1.setText("0");
else if(rightcp==1)
clulbl1.setText("1");
else if(rightcp==2)
clulbl1.setText("2");
else if(rightcp==3)
clulbl1.setText("3");

if(rightcol==0)
clulbl2.setText("0");
else if(rightcol==1)
clulbl2.setText("1");
else if(rightcol==2)
clulbl2.setText("2");
else if(rightcol==3)
clulbl2.setText("3");
pasaloadset=set;
if(rightcp==3 && set<=5)
{
win++;
sclbl1.setText(win+"");
JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;
}
else if ((rightcp<3) && (set==5))
{
set=0;
lose++;
sclbl2.setText(lose+"");
JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
}
pasaloadcp=rightcp;
rightcp=0;
rightcol=0;
in=0;
ctr=0;
tapos[0]=-1;
tapos[1]=-1;
tapos[2]=-1;
}
else if(set==2)
{
if(rightcp==0)
clulbl3.setText("0");
else if(rightcp==1)
clulbl3.setText("1");
else if(rightcp==2)
clulbl3.setText("2");
else if(rightcp==3)
clulbl3.setText("3");

if(rightcol==0)
clulbl4.setText("0");
else if(rightcol==1)
clulbl4.setText("1");
else if(rightcol==2)
clulbl4.setText("2");
else if(rightcol==3)
clulbl4.setText("3");
pasaloadset=set;
if(rightcp==3 && set<=5)
{
set=0;
win++;
sclbl1.setText(win+"");
JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
}

else if ((rightcp<3) && (set==5))
{
set=0;
lose++;
sclbl2.setText(lose+"");
JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);

}
pasaloadcp=rightcp;
rightcp=0;
rightcol=0;
in=0;
ctr=0;
tapos[0]=-1;
tapos[1]=-1;
tapos[2]=-1;

}
else if(set==3)
{
if(rightcp==0)
clulbl5.setText("0");
else if(rightcp==1)
clulbl5.setText("1");
else if(rightcp==2)
clulbl5.setText("2");
else if(rightcp==3)
clulbl5.setText("3");

if(rightcol==0)
clulbl6.setText("0");
else if(rightcol==1)
clulbl6.setText("1");
else if(rightcol==2)
clulbl6.setText("2");
else if(rightcol==3)
clulbl6.setText("3");
pasaloadset=set;
if(rightcp==3 && set<=5)
{
win++;
sclbl1.setText(win+"");
JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;

}
else if ((rightcp<3) && (set==5))
{
lose++;
sclbl2.setText(lose+"");
JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;
}
pasaloadcp=rightcp;
rightcp=0;
rightcol=0;
in=0;
ctr=0;
tapos[0]=-1;
tapos[1]=-1;
tapos[2]=-1;
}
else if(set==4)
{
if(rightcp==0)
clulbl7.setText("0");
else if(rightcp==1)
clulbl7.setText("1");
else if(rightcp==2)
clulbl7.setText("2");
else if(rightcp==3)
clulbl7.setText("3");

if(rightcol==0)
clulbl8.setText("0");
else if(rightcol==1)
clulbl8.setText("1");
else if(rightcol==2)
clulbl8.setText("2");
else if(rightcol==3)
clulbl8.setText("3");

pasaloadset=set;
if(rightcp==3 && set<=5)
{
win++;
sclbl1.setText(win+"");
JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;
}
else if ((rightcp<3) && (set==5))
{
lose++;
sclbl2.setText(lose+"");
JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;
}

pasaloadcp=rightcp;
rightcp=0;
rightcol=0;
in=0;
ctr=0;
tapos[0]=-1;
tapos[1]=-1;
tapos[2]=-1;
}
else if(set==5)
{
if(rightcp==0)
clulbl9.setText("0");
else if(rightcp==1)
clulbl9.setText("1");
else if(rightcp==2)
clulbl9.setText("2");
else if(rightcp==3)
clulbl9.setText("3");

if(rightcol==0)
clulbl10.setText("0");
else if(rightcol==1)
clulbl10.setText("1");
else if(rightcol==2)
clulbl10.setText("2");
else if(rightcol==3)
clulbl10.setText("3");

pasaloadset=set;
if(rightcp==3 && set<=5)
{
win++;
sclbl1.setText(win+"");
JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;

}
else if ((rightcp<3) && (set==5))
{
lose++;
sclbl2.setText(lose+"");
JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
set=0;
}
pasaloadcp=rightcp;
rightcp=0;
rightcol=0;
in=0;
ctr=0;
tapos[0]=-1;
tapos[1]=-1;
tapos[2]=-1;
}

if(pasaloadcp==3 && pasaloadset<=5)
{
/*******************************/
int intAns =JOptionPane.showConfirmDialog
(null, "Play Again?","Confirmation", JOptionPane.YES_NO_OPTION);
if (intAns == JOptionPane.YES_OPTION)
{
;
}
else
{
JOptionPane.showMessageDialog(null,"THANK YOU","",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
/***************************/
}
else if(pasaloadcp<3 && pasaloadset==5)
{
/*******************************/
int intAns =JOptionPane.showConfirmDialog
(null, "Play Again?","Confirmation", JOptionPane.YES_NO_OPTION);
if (intAns == JOptionPane.YES_OPTION)
;
else
{
JOptionPane.showMessageDialog(null,"Thank You!!!","",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
/***************************/
}
set=set+1;
}//if
}//class

}//class
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 18
Reputation: psylocke is an unknown quantity at this point 
Solved Threads: 0
psylocke psylocke is offline Offline
Newbie Poster

how will i repeat my whole program?

 
0
  #6
Sep 16th, 2004
sorry guys i thought i already attached my code.. but this is my program. the program is done except for a problem how to repeat the game once the player chooses the Yes button after he/she is asked to Play Again.

thanks for any help that u can give...
  1. import java.awt.*;
  2. import java.lang.Math;
  3. import java.applet.Applet;
  4. import javax.swing.*;
  5. import java.awt.event.*;
  6.  
  7.  
  8. public class mastermind extends Applet implements ActionListener
  9. {
  10.  
  11. int tri=0,put=1,set=1,t,in=0,w,n,ctr=0,c=0,x,win=0,lose=0,pasaloadcp=0,pasaloadset=0;
  12. int [] secretCol;
  13. int tapos[]={-1,-1,-1};
  14. int pickCol[];
  15. int copyy[];
  16.  
  17. Label peglbl1=new Label("");
  18. Label peglbl2=new Label("");
  19. Label peglbl3=new Label("");
  20. Label peglbl4=new Label("");
  21. Label peglbl5=new Label("");
  22. Label peglbl6=new Label("");
  23. Label peglbl7=new Label("");
  24. Label peglbl8=new Label("");
  25. Label peglbl9=new Label("");
  26. Label peglbl10=new Label("");
  27. Label peglbl11=new Label("");
  28. Label peglbl12=new Label("");
  29. Label peglbl13=new Label("");
  30. Label peglbl14=new Label("");
  31. Label peglbl15=new Label("");
  32. Button colbtn1=new Button();
  33. Button colbtn2=new Button();
  34. Button colbtn3=new Button();
  35. Button colbtn4=new Button();
  36. Button colbtn5=new Button();
  37. Button colbtn6=new Button();
  38. Label gnolbl1=new Label("Guess #1");
  39. Label gnolbl2=new Label("Guess #2");
  40. Label gnolbl3=new Label("Guess #3");
  41. Label gnolbl4=new Label("Guess #4");
  42. Label gnolbl5=new Label("Guess #5");
  43. Label winlbl=new Label("WIN");
  44. Label loselbl=new Label("LOSE");
  45. Label clulbl1=new Label("");
  46. Label clulbl2=new Label("");
  47. Label clulbl3=new Label("");
  48. Label clulbl4=new Label("");
  49. Label clulbl5=new Label("");
  50. Label clulbl6=new Label("");
  51. Label clulbl7=new Label("");
  52. Label clulbl8=new Label("");
  53. Label clulbl9=new Label("");
  54. Label clulbl10=new Label("");
  55. Label clulbl12=new Label("");
  56.  
  57.  
  58. Label blbl2=new Label("");
  59. Label blbl4=new Label("");
  60.  
  61. //Label slbl2=new Label("");
  62. //Label slbl3=new Label("");
  63. //Label slbl4=new Label("");
  64.  
  65. Label sclbl1=new Label("0");
  66. Label sclbl2=new Label("0");
  67.  
  68. public void init()
  69. {
  70.  
  71. pickCol=new int[3];
  72. tapos=new int[3];
  73. copyy=new int[3];
  74.  
  75. setLayout(new GridLayout(8,6,5,5));
  76. colbtn1.addActionListener(this);
  77. colbtn2.addActionListener(this);
  78. colbtn3.addActionListener(this);
  79. colbtn4.addActionListener(this);
  80. colbtn5.addActionListener(this);
  81. colbtn6.addActionListener(this);
  82.  
  83. add(gnolbl1);
  84. add(peglbl1);
  85. add(peglbl2);
  86. add(peglbl3);
  87. add(clulbl1);
  88. add(clulbl2);
  89.  
  90. add(gnolbl2);
  91. add(peglbl4);
  92. add(peglbl5);
  93. add(peglbl6);
  94. add(clulbl3);
  95. add(clulbl4);
  96.  
  97. add(gnolbl3);
  98. add(peglbl7);
  99. add(peglbl8);
  100. add(peglbl9);
  101. add(clulbl5);
  102. add(clulbl6);
  103.  
  104. add(gnolbl4);
  105. add(peglbl10);
  106. add(peglbl11);
  107. add(peglbl12);
  108. add(clulbl7);
  109. add(clulbl8);
  110.  
  111. add(gnolbl5);
  112. add(peglbl13);
  113. add(peglbl14);
  114. add(peglbl15);
  115. add(clulbl9);
  116. add(clulbl10);
  117.  
  118. add(colbtn1);
  119. add(colbtn2);
  120. add(colbtn3);
  121. add(colbtn4);
  122. add(colbtn5);
  123. add(colbtn6);
  124.  
  125. peglbl1.setBackground(Color.DARK_GRAY);
  126. peglbl2.setBackground(Color.DARK_GRAY);
  127. peglbl3.setBackground(Color.DARK_GRAY);
  128. peglbl4.setBackground(Color.DARK_GRAY);
  129. peglbl5.setBackground(Color.DARK_GRAY);
  130. peglbl6.setBackground(Color.DARK_GRAY);
  131. peglbl7.setBackground(Color.DARK_GRAY);
  132. peglbl8.setBackground(Color.DARK_GRAY);
  133. peglbl9.setBackground(Color.DARK_GRAY);
  134. peglbl10.setBackground(Color.DARK_GRAY);
  135. peglbl11.setBackground(Color.DARK_GRAY);
  136. peglbl12.setBackground(Color.DARK_GRAY);
  137. peglbl13.setBackground(Color.DARK_GRAY);
  138. peglbl14.setBackground(Color.DARK_GRAY);
  139. peglbl15.setBackground(Color.DARK_GRAY);
  140.  
  141. gnolbl1.setBackground(Color.LIGHT_GRAY);
  142. gnolbl2.setBackground(Color.LIGHT_GRAY);
  143. gnolbl3.setBackground(Color.LIGHT_GRAY);
  144. gnolbl4.setBackground(Color.LIGHT_GRAY);
  145. gnolbl5.setBackground(Color.LIGHT_GRAY);
  146.  
  147. clulbl1.setBackground(Color.LIGHT_GRAY);
  148. clulbl2.setBackground(Color.LIGHT_GRAY);
  149. clulbl3.setBackground(Color.LIGHT_GRAY);
  150. clulbl4.setBackground(Color.LIGHT_GRAY);
  151. clulbl5.setBackground(Color.LIGHT_GRAY);
  152. clulbl6.setBackground(Color.LIGHT_GRAY);
  153. clulbl7.setBackground(Color.LIGHT_GRAY);
  154. clulbl8.setBackground(Color.LIGHT_GRAY);
  155. clulbl9.setBackground(Color.LIGHT_GRAY);
  156. clulbl10.setBackground(Color.LIGHT_GRAY);
  157.  
  158. colbtn1.setLabel("Green");
  159. colbtn2.setLabel("Blue");
  160. colbtn3.setLabel("Red");
  161. colbtn4.setLabel("Yellow");
  162. colbtn5.setLabel("Orange");
  163. colbtn6.setLabel("Magenta");
  164. colbtn1.setBackground(Color.GREEN);
  165. colbtn2.setBackground(Color.BLUE);
  166. colbtn3.setBackground(Color.RED);
  167. colbtn4.setBackground(Color.YELLOW);
  168. colbtn5.setBackground(Color.ORANGE);
  169. colbtn6.setBackground(Color.MAGENTA);
  170.  
  171.  
  172. add(winlbl);
  173. add(sclbl1);
  174. add(blbl2);
  175. add(loselbl);
  176. add(sclbl2);
  177. add(blbl4);
  178.  
  179.  
  180. //add(slbl2);
  181. //add(slbl3);
  182. //add(slbl4);
  183.  
  184. }//init
  185.  
  186. public void start()
  187. {
  188. double m;
  189. int k,a;
  190. secretCol=new int[3];
  191. for(a=0;a<3;a++)
  192. {
  193. secretCol[a]=-1;
  194. while(secretCol[a]<0)
  195. {
  196. m=Math.random();
  197. k=(int) Math.floor((m*6)+1);
  198. secretCol[a]=k;
  199. }
  200. }
  201.  
  202. for(a=0;a<3;a++)
  203. {
  204. if(a==0)
  205. {
  206. if(secretCol[a]==1)
  207. slbl2.setBackground(Color.GREEN);
  208. else if(secretCol[a]==2)
  209. slbl2.setBackground(Color.BLUE);
  210. else if(secretCol[a]==3)
  211. slbl2.setBackground(Color.RED);
  212. else if(secretCol[a]==4)
  213. slbl2.setBackground(Color.YELLOW);
  214. else if(secretCol[a]==5)
  215. slbl2.setBackground(Color.ORANGE);
  216. else if(secretCol[a]==6)
  217. slbl2.setBackground(Color.MAGENTA);
  218. }
  219. else if(a==1)
  220. {
  221. if(secretCol[a]==1)
  222. slbl3.setBackground(Color.GREEN);
  223. else if(secretCol[a]==2)
  224. slbl3.setBackground(Color.BLUE);
  225. else if(secretCol[a]==3)
  226. slbl3.setBackground(Color.RED);
  227. else if(secretCol[a]==4)
  228. slbl3.setBackground(Color.YELLOW);
  229. else if(secretCol[a]==5)
  230. slbl3.setBackground(Color.ORANGE);
  231. else if(secretCol[a]==6)
  232. slbl3.setBackground(Color.MAGENTA);
  233. }
  234. else if(a==2)
  235. {
  236. if(secretCol[a]==1)
  237. slbl4.setBackground(Color.GREEN);
  238. else if(secretCol[a]==2)
  239. slbl4.setBackground(Color.BLUE);
  240. else if(secretCol[a]==3)
  241. slbl4.setBackground(Color.RED);
  242. else if(secretCol[a]==4)
  243. slbl4.setBackground(Color.YELLOW);
  244. else if(secretCol[a]==5)
  245. slbl4.setBackground(Color.ORANGE);
  246. else if(secretCol[a]==6)
  247. slbl4.setBackground(Color.MAGENTA);
  248. }
  249. }
  250. }//clrBoard
  251.  
  252. public void actionPerformed(ActionEvent ae)
  253. {
  254.  
  255. int rightcp=0,rightcol=0;
  256. int what=0;
  257.  
  258. tri++;
  259. if(ae.getSource()==colbtn1)
  260. {
  261. if(tri==1)
  262. peglbl1.setBackground(Color.GREEN);
  263. else if(tri==2)
  264. peglbl2.setBackground(Color.GREEN);
  265. else if(tri==3)
  266. peglbl3.setBackground(Color.GREEN);
  267. else if(tri==4)
  268. peglbl4.setBackground(Color.GREEN);
  269. else if(tri==5)
  270. peglbl5.setBackground(Color.GREEN);
  271. else if(tri==6)
  272. peglbl6.setBackground(Color.GREEN);
  273. else if(tri==7)
  274. peglbl7.setBackground(Color.GREEN);
  275. else if(tri==8)
  276. peglbl8.setBackground(Color.GREEN);
  277. else if(tri==9)
  278. peglbl9.setBackground(Color.GREEN);
  279. else if(tri==10)
  280. peglbl10.setBackground(Color.GREEN);
  281. else if(tri==11)
  282. peglbl11.setBackground(Color.GREEN);
  283. else if(tri==12)
  284. peglbl12.setBackground(Color.GREEN);
  285. else if(tri==13)
  286. peglbl13.setBackground(Color.GREEN);
  287. else if(tri==14)
  288. peglbl14.setBackground(Color.GREEN);
  289. else if(tri==15)
  290. peglbl15.setBackground(Color.GREEN);
  291. what=1;
  292. }
  293. else if(ae.getSource()==colbtn2)
  294. {
  295.  
  296. if(tri==1)
  297. peglbl1.setBackground(Color.BLUE);
  298. else if(tri==2)
  299. peglbl2.setBackground(Color.BLUE);
  300. else if(tri==3)
  301. peglbl3.setBackground(Color.BLUE);
  302. else if(tri==4)
  303. peglbl4.setBackground(Color.BLUE);
  304. else if(tri==5)
  305. peglbl5.setBackground(Color.BLUE);
  306. else if(tri==6)
  307. peglbl6.setBackground(Color.BLUE);
  308. else if(tri==7)
  309. peglbl7.setBackground(Color.BLUE);
  310. else if(tri==8)
  311. peglbl8.setBackground(Color.BLUE);
  312. else if(tri==9)
  313. peglbl9.setBackground(Color.BLUE);
  314. else if(tri==10)
  315. peglbl10.setBackground(Color.BLUE);
  316. else if(tri==11)
  317. peglbl11.setBackground(Color.BLUE);
  318. else if(tri==12)
  319. peglbl12.setBackground(Color.BLUE);
  320. else if(tri==13)
  321. peglbl13.setBackground(Color.BLUE);
  322. else if(tri==14)
  323. peglbl14.setBackground(Color.BLUE);
  324. else if(tri==15)
  325. peglbl15.setBackground(Color.BLUE);
  326. what=2;
  327. }
  328. else if(ae.getSource()==colbtn3)
  329. {
  330. if(tri==1)
  331. peglbl1.setBackground(Color.RED);
  332. else if(tri==2)
  333. peglbl2.setBackground(Color.RED);
  334. else if(tri==3)
  335. peglbl3.setBackground(Color.RED);
  336. else if(tri==4)
  337. peglbl4.setBackground(Color.RED);
  338. else if(tri==5)
  339. peglbl5.setBackground(Color.RED);
  340. else if(tri==6)
  341. peglbl6.setBackground(Color.RED);
  342. else if(tri==7)
  343. peglbl7.setBackground(Color.RED);
  344. else if(tri==8)
  345. peglbl8.setBackground(Color.RED);
  346. else if(tri==9)
  347. peglbl9.setBackground(Color.RED);
  348. else if(tri==10)
  349. peglbl10.setBackground(Color.RED);
  350. else if(tri==11)
  351. peglbl11.setBackground(Color.RED);
  352. else if(tri==12)
  353. peglbl12.setBackground(Color.RED);
  354. else if(tri==13)
  355. peglbl13.setBackground(Color.RED);
  356. else if(tri==14)
  357. peglbl14.setBackground(Color.RED);
  358. else if(tri==15)
  359. peglbl15.setBackground(Color.RED);
  360. what=3;
  361. }
  362. else if(ae.getSource()==colbtn4)
  363. {
  364. if(tri==1)
  365. peglbl1.setBackground(Color.YELLOW);
  366. else if(tri==2)
  367. peglbl2.setBackground(Color.YELLOW);
  368. else if(tri==3)
  369. peglbl3.setBackground(Color.YELLOW);
  370. else if(tri==4)
  371. peglbl4.setBackground(Color.YELLOW);
  372. else if(tri==5)
  373. peglbl5.setBackground(Color.YELLOW);
  374. else if(tri==6)
  375. peglbl6.setBackground(Color.YELLOW);
  376. else if(tri==7)
  377. peglbl7.setBackground(Color.YELLOW);
  378. else if(tri==8)
  379. peglbl8.setBackground(Color.YELLOW);
  380. else if(tri==9)
  381. peglbl9.setBackground(Color.YELLOW);
  382. else if(tri==10)
  383. peglbl10.setBackground(Color.YELLOW);
  384. else if(tri==11)
  385. peglbl11.setBackground(Color.YELLOW);
  386. else if(tri==12)
  387. peglbl12.setBackground(Color.YELLOW);
  388. else if(tri==13)
  389. peglbl13.setBackground(Color.YELLOW);
  390. else if(tri==14)
  391. peglbl14.setBackground(Color.YELLOW);
  392. else if (tri==15)
  393. peglbl15.setBackground(Color.YELLOW);
  394. what=4;
  395. }
  396. else if(ae.getSource()==colbtn5)
  397. {
  398. if(tri==1)
  399. peglbl1.setBackground(Color.ORANGE);
  400. else if(tri==2)
  401. peglbl2.setBackground(Color.ORANGE);
  402. else if(tri==3)
  403. peglbl3.setBackground(Color.ORANGE);
  404. else if(tri==4)
  405. peglbl4.setBackground(Color.ORANGE);
  406. else if(tri==5)
  407. peglbl5.setBackground(Color.ORANGE);
  408. else if(tri==6)
  409. peglbl6.setBackground(Color.ORANGE);
  410. else if(tri==7)
  411. peglbl7.setBackground(Color.ORANGE);
  412. else if(tri==8)
  413. peglbl8.setBackground(Color.ORANGE);
  414. else if(tri==9)
  415. peglbl9.setBackground(Color.ORANGE);
  416. else if(tri==10)
  417. peglbl10.setBackground(Color.ORANGE);
  418. else if(tri==11)
  419. peglbl11.setBackground(Color.ORANGE);
  420. else if(tri==12)
  421. peglbl12.setBackground(Color.ORANGE);
  422. else if(tri==13)
  423. peglbl13.setBackground(Color.ORANGE);
  424. else if(tri==14)
  425. peglbl14.setBackground(Color.ORANGE);
  426. else if(tri==15)
  427. peglbl15.setBackground(Color.ORANGE);
  428. what=5;
  429. }
  430. else if(ae.getSource()==colbtn6)
  431. {
  432. if(tri==1)
  433. peglbl1.setBackground(Color.MAGENTA);
  434. else if(tri==2)
  435. peglbl2.setBackground(Color.MAGENTA);
  436. else if(tri==3)
  437. peglbl3.setBackground(Color.MAGENTA);
  438. else if(tri==4)
  439. peglbl4.setBackground(Color.MAGENTA);
  440. else if(tri==5)
  441. peglbl5.setBackground(Color.MAGENTA);
  442. else if(tri==6)
  443. peglbl6.setBackground(Color.MAGENTA);
  444. else if(tri==7)
  445. peglbl7.setBackground(Color.MAGENTA);
  446. else if(tri==8)
  447. peglbl8.setBackground(Color.MAGENTA);
  448. else if(tri==9)
  449. peglbl9.setBackground(Color.MAGENTA);
  450. else if(tri==10)
  451. peglbl10.setBackground(Color.MAGENTA);
  452. else if(tri==11)
  453. peglbl11.setBackground(Color.MAGENTA);
  454. else if(tri==12)
  455. peglbl12.setBackground(Color.MAGENTA);
  456. else if(tri==13)
  457. peglbl13.setBackground(Color.MAGENTA);
  458. else if(tri==14)
  459. peglbl14.setBackground(Color.MAGENTA);
  460. else if(tri==15)
  461. peglbl15.setBackground(Color.MAGENTA);
  462. what=6;
  463. }
  464.  
  465. ctr=ctr+1;
  466. pickCol[in++]=what;
  467.  
  468. if(ctr==3)
  469. {
  470.  
  471. for(w=0;w<3;w++)
  472. copyy[w]=secretCol[w];
  473.  
  474. for(w=0;w<3;w++)
  475. {
  476.  
  477. if(pickCol[w]==secretCol[w])
  478. {
  479. rightcp=rightcp+1;
  480. tapos[w]=pickCol[w];
  481. }
  482. }
  483.  
  484. for(w=0;w<3;w++)
  485. for(x=0;x<3;x++)
  486. if(pickCol[w]==tapos[w])
  487. break;
  488. else if(w==x)
  489. continue;
  490. else if(pickCol[w]==tapos[x])
  491. continue;
  492. else if(pickCol[w]==copyy[x])
  493. {
  494. rightcol=rightcol+1;
  495. copyy[x]=-1;
  496. break;
  497. }
  498.  
  499.  
  500. if(set==1)
  501. {
  502. if(rightcp==0)
  503. clulbl1.setText("0");
  504. else if(rightcp==1)
  505. clulbl1.setText("1");
  506. else if(rightcp==2)
  507. clulbl1.setText("2");
  508. else if(rightcp==3)
  509. clulbl1.setText("3");
  510.  
  511. if(rightcol==0)
  512. clulbl2.setText("0");
  513. else if(rightcol==1)
  514. clulbl2.setText("1");
  515. else if(rightcol==2)
  516. clulbl2.setText("2");
  517. else if(rightcol==3)
  518. clulbl2.setText("3");
  519. pasaloadset=set;
  520. if(rightcp==3 && set<=5)
  521. {
  522. win++;
  523. sclbl1.setText(win+"");
  524. JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
  525. set=0;
  526. }
  527. else if ((rightcp<3) && (set==5))
  528. {
  529. set=0;
  530. lose++;
  531. sclbl2.setText(lose+"");
  532. JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
  533. }
  534. pasaloadcp=rightcp;
  535. rightcp=0;
  536. rightcol=0;
  537. in=0;
  538. ctr=0;
  539. tapos[0]=-1;
  540. tapos[1]=-1;
  541. tapos[2]=-1;
  542. }
  543. else if(set==2)
  544. {
  545. if(rightcp==0)
  546. clulbl3.setText("0");
  547. else if(rightcp==1)
  548. clulbl3.setText("1");
  549. else if(rightcp==2)
  550. clulbl3.setText("2");
  551. else if(rightcp==3)
  552. clulbl3.setText("3");
  553.  
  554. if(rightcol==0)
  555. clulbl4.setText("0");
  556. else if(rightcol==1)
  557. clulbl4.setText("1");
  558. else if(rightcol==2)
  559. clulbl4.setText("2");
  560. else if(rightcol==3)
  561. clulbl4.setText("3");
  562. pasaloadset=set;
  563. if(rightcp==3 && set<=5)
  564. {
  565. set=0;
  566. win++;
  567. sclbl1.setText(win+"");
  568. JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
  569. }
  570.  
  571. else if ((rightcp<3) && (set==5))
  572. {
  573. set=0;
  574. lose++;
  575. sclbl2.setText(lose+"");
  576. JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
  577.  
  578. }
  579. pasaloadcp=rightcp;
  580. rightcp=0;
  581. rightcol=0;
  582. in=0;
  583. ctr=0;
  584. tapos[0]=-1;
  585. tapos[1]=-1;
  586. tapos[2]=-1;
  587.  
  588. }
  589. else if(set==3)
  590. {
  591. if(rightcp==0)
  592. clulbl5.setText("0");
  593. else if(rightcp==1)
  594. clulbl5.setText("1");
  595. else if(rightcp==2)
  596. clulbl5.setText("2");
  597. else if(rightcp==3)
  598. clulbl5.setText("3");
  599.  
  600. if(rightcol==0)
  601. clulbl6.setText("0");
  602. else if(rightcol==1)
  603. clulbl6.setText("1");
  604. else if(rightcol==2)
  605. clulbl6.setText("2");
  606. else if(rightcol==3)
  607. clulbl6.setText("3");
  608. pasaloadset=set;
  609. if(rightcp==3 && set<=5)
  610. {
  611. win++;
  612. sclbl1.setText(win+"");
  613. JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
  614. set=0;
  615.  
  616. }
  617. else if ((rightcp<3) && (set==5))
  618. {
  619. lose++;
  620. sclbl2.setText(lose+"");
  621. JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
  622. set=0;
  623. }
  624. pasaloadcp=rightcp;
  625. rightcp=0;
  626. rightcol=0;
  627. in=0;
  628. ctr=0;
  629. tapos[0]=-1;
  630. tapos[1]=-1;
  631. tapos[2]=-1;
  632. }
  633. else if(set==4)
  634. {
  635. if(rightcp==0)
  636. clulbl7.setText("0");
  637. else if(rightcp==1)
  638. clulbl7.setText("1");
  639. else if(rightcp==2)
  640. clulbl7.setText("2");
  641. else if(rightcp==3)
  642. clulbl7.setText("3");
  643.  
  644. if(rightcol==0)
  645. clulbl8.setText("0");
  646. else if(rightcol==1)
  647. clulbl8.setText("1");
  648. else if(rightcol==2)
  649. clulbl8.setText("2");
  650. else if(rightcol==3)
  651. clulbl8.setText("3");
  652.  
  653. pasaloadset=set;
  654. if(rightcp==3 && set<=5)
  655. {
  656. win++;
  657. sclbl1.setText(win+"");
  658. JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
  659. set=0;
  660. }
  661. else if ((rightcp<3) && (set==5))
  662. {
  663. lose++;
  664. sclbl2.setText(lose+"");
  665. JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
  666. set=0;
  667. }
  668.  
  669. pasaloadcp=rightcp;
  670. rightcp=0;
  671. rightcol=0;
  672. in=0;
  673. ctr=0;
  674. tapos[0]=-1;
  675. tapos[1]=-1;
  676. tapos[2]=-1;
  677. }
  678. else if(set==5)
  679. {
  680. if(rightcp==0)
  681. clulbl9.setText("0");
  682. else if(rightcp==1)
  683. clulbl9.setText("1");
  684. else if(rightcp==2)
  685. clulbl9.setText("2");
  686. else if(rightcp==3)
  687. clulbl9.setText("3");
  688.  
  689. if(rightcol==0)
  690. clulbl10.setText("0");
  691. else if(rightcol==1)
  692. clulbl10.setText("1");
  693. else if(rightcol==2)
  694. clulbl10.setText("2");
  695. else if(rightcol==3)
  696. clulbl10.setText("3");
  697.  
  698. pasaloadset=set;
  699. if(rightcp==3 && set<=5)
  700. {
  701. win++;
  702. sclbl1.setText(win+"");
  703. JOptionPane.showMessageDialog(null,"Congratulations you WIN!!!","Resulta",JOptionPane.INFORMATION_MESSAGE);
  704. set=0;
  705.  
  706. }
  707. else if ((rightcp<3) && (set==5))
  708. {
  709. lose++;
  710. sclbl2.setText(lose+"");
  711. JOptionPane.showMessageDialog(null,"Sorry you LOSE.","Resulta",JOptionPane.INFORMATION_MESSAGE);
  712. set=0;
  713. }
  714. pasaloadcp=rightcp;
  715. rightcp=0;
  716. rightcol=0;
  717. in=0;
  718. ctr=0;
  719. tapos[0]=-1;
  720. tapos[1]=-1;
  721. tapos[2]=-1;
  722. }
  723.  
  724. if(pasaloadcp==3 && pasaloadset<=5)
  725. {
  726. /*******************************/
  727. int intAns =JOptionPane.showConfirmDialog
  728. (null, "Play Again?","Confirmation", JOptionPane.YES_NO_OPTION);
  729. if (intAns == JOptionPane.YES_OPTION)
  730. {
  731. ;
  732. }
  733. else
  734. {
  735. JOptionPane.showMessageDialog(null,"THANK YOU","",JOptionPane.INFORMATION_MESSAGE);
  736. System.exit(0);
  737. }
  738. /***************************/
  739. }
  740. else if(pasaloadcp<3 && pasaloadset==5)
  741. {
  742. /*******************************/
  743. int intAns =JOptionPane.showConfirmDialog
  744. (null, "Play Again?","Confirmation", JOptionPane.YES_NO_OPTION);
  745. if (intAns == JOptionPane.YES_OPTION)
  746. ;
  747. else
  748. {
  749. JOptionPane.showMessageDialog(null,"Thank You!!!","",JOptionPane.INFORMATION_MESSAGE);
  750. System.exit(0);
  751. }
  752. /***************************/
  753. }
  754. set=set+1;
  755. }//if
  756. }//class
  757.  
  758. }//class
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: how will i repeat my whole game program?

 
0
  #7
Sep 16th, 2004
Does your program compile ?? I dont think so because I didnt see any DARK_GRAY and LIGHT_GRAY colors in the color class ... they were darkGray and lightGray.. ??
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 18
Reputation: psylocke is an unknown quantity at this point 
Solved Threads: 0
psylocke psylocke is offline Offline
Newbie Poster

Re: how will i repeat my whole game program?

 
0
  #8
Sep 17th, 2004
Originally Posted by nanosani
Does your program compile ?? I dont think so because I didnt see any DARK_GRAY and LIGHT_GRAY colors in the color class ... they were darkGray and lightGray.. ??
yes my program compiles with no errors on it, this is 100% sure. i have tested it and its working with the only problem that i cant repeat it, u will notice from the bottom part of this program the statement that i have mentioned to execute is a ; character because i dont know what to place there once Yes button is pressed.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: how will i repeat my whole game program?

 
0
  #9
Sep 17th, 2004
It's not even compiling in my compiler ... I use JBuilder7 with jdk 1.4 ... ?? which compiler do you use to compile?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 18
Reputation: psylocke is an unknown quantity at this point 
Solved Threads: 0
psylocke psylocke is offline Offline
Newbie Poster

Re: how will i repeat my whole game program?

 
0
  #10
Sep 18th, 2004
Originally Posted by nanosani
It's not even compiling in my compiler ... I use JBuilder7 with jdk 1.4 ... ?? which compiler do you use to compile?
its jdk 1.4.2
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC