944,048 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1710
  • Java RSS
Sep 17th, 2004
0

i need help with my program guys, how to

Expand Post »
how am i going to repeat my whole game program? i dont know what to do. i have the codes below. and this program is already running, i have compiled it and it has no syntax and logical error, this is mastermind game. my only problem is how am i going to repeat this whole game once the player pressed the YEs button after he/she is asked if he/she wants to Play AGain.

any help will be of utmost appreciation. thanks.

Java Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 11
Solved Threads: 0
Newbie Poster
psylocke is offline Offline
18 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Window class problem(iam a new bee)
Next Thread in Java Forum Timeline: creating dynamic textfields





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC