Sauvegarder le fichier suivant dans Yams.java
/* Code : Frouin Jean-Michel eMail : jm@frouin.me Date : 23/06/2003 Style : Yams game enhanced ! Use : Free for non commercial use */ import java.awt.*; import java.awt.event.*; import java.applet.*; import java.util.Random; public class Yams extends Applet implements ActionListener{ Panel pMain; Panel pNom; // (1) Panel pour les noms Label lNom; Label lNom2; Panel pScores; // (2) Panel avec les scores du joueur Label lScoresJ[] = new Label[15]; // Les 14 combinaisons + bonus Button bCol1J[] = new Button[15]; Button bCol2J[] = new Button[15]; Button bCol3J[] = new Button[15]; Label lHighScore[] = new Label[15]; //Highscore Label lScore[] = new Label[15]; Panel pDes; // (3) Panel des Des Button bDes[] = new Button[5]; Panel pButtons; // (4) Panel des buttons Button bButtons[] = new Button[5]; Panel pStatus; //Panel du status Label lStatus[] = new Label[2]; int lance = 0; //Nombre de lance de Des int Des[] = new int[5]; // Des bloques int Col1J[] = new int[15]; // Stockage des scores int Col2J[] = new int[15]; int Col3J[] = new int[15]; int Descend=0; int Monte=13; int scorable=0; int ttJ=0; int joue=0; Random nb = new Random(); String combi[] = {"1","2","3","4","5","6","+30","-11","Petit","Grand","Carre","Full","Quinte","Yams"}; String menu[] = {"Lancer les dès","Envoyer son score","Nouvelle Partie","A Propos","Quitter"}; public void init(){ for(int i=0;i<5;i++) { Des[i]=0; //Des libres } for(int i=0;i<14;i++) { Col1J[i]=0; Col2J[i]=0; Col3J[i]=0; } setBackground(Color.white); setLayout(new BorderLayout()); pNom = new Panel(new GridLayout(1,4)); lNom = new Label("Concours de Yams 2004",Label.CENTER); lNom.setBackground(Color.cyan); lNom2 = new Label("Sponsorisé par les gommes : gom'tout",Label.CENTER); lNom2.setBackground(Color.cyan); pNom.add(lNom); pNom.add(lNom2); pStatus = new Panel(new GridLayout(1,2)); lStatus[0] = new Label("Infos diverses",Label.CENTER); lStatus[1] = new Label("Infos diverses",Label.CENTER); pStatus.add(lStatus[0]); pStatus.add(lStatus[1]); pScores = new Panel(new GridLayout(15,8)); for(int i=0;i<14;i++) { lScoresJ[i] = new Label(combi[i],Label.CENTER); lScoresJ[i].setBackground(Color.cyan); pScores.add(lScoresJ[i]); bCol1J[i] = new Button("0"); bCol1J[i].setBackground(Color.white); pScores.add(bCol1J[i]); bCol2J[i] = new Button("0"); bCol2J[i].setBackground(Color.white); pScores.add(bCol2J[i]); bCol3J[i] = new Button("0"); bCol3J[i].setBackground(Color.white); pScores.add(bCol3J[i]); lHighScore[i] = new Label("Snoogie ",Label.CENTER); lHighScore[i].setBackground(Color.cyan); pScores.add(lHighScore[i]); lScore[i] = new Label("1000",Label.CENTER); lScore[i].setBackground(Color.cyan); pScores.add(lScore[i]); } lScoresJ[14] = new Label("Total",Label.CENTER); bCol1J[14] = new Button("0"); bCol2J[14] = new Button("0"); bCol3J[14] = new Button("0"); bCol1J[14].setBackground(Color.cyan); bCol1J[14].setEnabled(false); bCol2J[14].setBackground(Color.cyan); bCol2J[14].setEnabled(false); bCol3J[14].setBackground(Color.cyan); bCol3J[14].setEnabled(false); bCol1J[6].setEnabled(false); bCol2J[6].setEnabled(false); bCol3J[6].setEnabled(false); pScores.add(lScoresJ[14]); pScores.add(bCol1J[14]); pScores.add(bCol2J[14]); pScores.add(bCol3J[14]); lHighScore[0].setText("Noms"); lHighScore[0].setBackground(Color.pink); lScore[0].setText("Scores"); lScore[0].setBackground(Color.pink); lHighScore[13].setText("_________________________"); lScore[13].setText("_________________________"); lHighScore[13].setBackground(Color.cyan); lScore[13].setBackground(Color.cyan); lHighScore[14] = new Label("Total",Label.CENTER); pScores.add(lHighScore[14]); lScore[14] = new Label(); pScores.add(lScore[14]); pDes = new Panel(new GridLayout(1,5)); for(int i=0;i<5;i++) { bDes[i] = new Button("De "+(i+1)); bDes[i].setBackground(Color.white); pDes.add(bDes[i]); } pButtons = new Panel(new GridLayout(1,5)); for(int i=0;i<5;i++) { bButtons[i] = new Button(menu[i]); bButtons[i].setBackground(Color.white); bButtons[i].addActionListener(this); } bButtons[1].setEnabled(false); for(int i=0;i<5;i++) { pButtons.add(bButtons[i]); } pMain = new Panel(new GridLayout(5,3)); pMain.add(pDes); pMain.add(pStatus); pMain.add(pButtons); add("North",pNom); add("Center",pScores); add("South",pMain); //Ecouter boutons "Lancer Des" bButtons[0].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(lance!=4){ System.out.println("Lance les des"); Lance_Des();} else { lStatus[0].setText("Vous devez choisir un score !!"); } } }); // Envoyer mail //Ecouteur des des ... Dédé bDes[0].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(lance!=4) { if(Des[0]==0 && lance!=0) { Des[0] = 1; bDes[0].setBackground(Color.red); } else { Des[0] = 0; bDes[0].setBackground(Color.white); } } }}); bDes[1].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(lance!=4) { if(Des[1]==0 && lance!=0) { Des[1] = 1; bDes[1].setBackground(Color.red); } else { Des[1] = 0; bDes[1].setBackground(Color.white); } } }}); bDes[2].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(lance!=4) { if(Des[2]==0 && lance!=0) { Des[2] = 1; bDes[2].setBackground(Color.red); } else { Des[2] = 0; bDes[2].setBackground(Color.white); } } }}); bDes[3].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(lance!=4) { if(Des[3]==0 && lance!=0) { Des[3] = 1; bDes[3].setBackground(Color.red); } else { Des[3] = 0; bDes[3].setBackground(Color.white); } } }}); bDes[4].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(lance!=4) { if(Des[4]==0 && lance!=0) { Des[4] = 1; bDes[4].setBackground(Color.red); } else { Des[4] = 0; bDes[4].setBackground(Color.white); } } }}); //Ecouteurs des bcols bCol1J[0].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[0].setBackground(Color.yellow); bCol1J[0].setEnabled(false); fin_tour(); }}); bCol1J[1].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[1].setBackground(Color.yellow); bCol1J[1].setEnabled(false); fin_tour(); }}); bCol1J[2].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[2].setBackground(Color.yellow); bCol1J[2].setEnabled(false); fin_tour(); }}); bCol1J[3].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[3].setBackground(Color.yellow); bCol1J[3].setEnabled(false); fin_tour(); }}); bCol1J[4].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[4].setBackground(Color.yellow); bCol1J[4].setEnabled(false); fin_tour(); }}); bCol1J[5].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[5].setBackground(Color.yellow); bCol1J[5].setEnabled(false); fin_tour(); }}); bCol1J[6].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[6].setBackground(Color.yellow); bCol1J[6].setEnabled(false); fin_tour(); }}); bCol1J[7].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[7].setBackground(Color.yellow); bCol1J[7].setEnabled(false); fin_tour(); }}); bCol1J[8].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[8].setBackground(Color.yellow); bCol1J[8].setEnabled(false); fin_tour(); }}); bCol1J[9].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[9].setBackground(Color.yellow); bCol1J[9].setEnabled(false); fin_tour(); }}); bCol1J[10].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[10].setBackground(Color.yellow); bCol1J[10].setEnabled(false); fin_tour(); }}); bCol1J[11].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[11].setBackground(Color.yellow); bCol1J[11].setEnabled(false); fin_tour(); }}); bCol1J[12].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[12].setBackground(Color.yellow); bCol1J[12].setEnabled(false); fin_tour(); }}); bCol1J[13].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bCol1J[13].setBackground(Color.yellow); bCol1J[13].setEnabled(false); fin_tour(); }}); bCol2J[0].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==0) { bCol2J[0].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[0].setEnabled(false); fin_tour(); } }}); bCol2J[1].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==1) { bCol2J[1].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[1].setEnabled(false); fin_tour(); } }}); bCol2J[2].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==2) { bCol2J[2].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[2].setEnabled(false); fin_tour(); } }}); bCol2J[3].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==3) { bCol2J[3].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[3].setEnabled(false); fin_tour(); } }}); bCol2J[4].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==4) { bCol2J[4].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[4].setEnabled(false); fin_tour(); } }}); bCol2J[5].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==5) { bCol2J[5].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[5].setEnabled(false); fin_tour(); } }}); bCol2J[6].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==6) { bCol2J[6].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[6].setEnabled(false); fin_tour(); } }}); bCol2J[7].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==7) { bCol2J[7].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[7].setEnabled(false); fin_tour(); } }}); bCol2J[8].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==8) { bCol2J[8].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[8].setEnabled(false); fin_tour(); } }}); bCol2J[9].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==9) { bCol2J[9].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[9].setEnabled(false); fin_tour(); } }}); bCol2J[10].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==10) { bCol2J[10].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[10].setEnabled(false); fin_tour(); } }}); bCol2J[11].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==11) { bCol2J[11].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[11].setEnabled(false); fin_tour(); } }}); bCol2J[12].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==12) { bCol2J[12].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[12].setEnabled(false); fin_tour(); } }}); bCol2J[13].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Descend==13) { bCol2J[13].setBackground(Color.yellow); Descend++; if(Descend==6) Descend++; bCol2J[13].setEnabled(false); fin_tour(); } }}); bCol3J[0].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==0) { bCol3J[0].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[0].setEnabled(false); fin_tour(); } }}); bCol3J[1].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==1) { bCol3J[1].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[1].setEnabled(false); fin_tour(); } }}); bCol3J[2].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==2) { bCol3J[2].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[2].setEnabled(false); fin_tour(); } }}); bCol3J[3].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==3) { bCol3J[3].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[3].setEnabled(false); fin_tour(); } }}); bCol3J[4].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==4) { bCol3J[4].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[4].setEnabled(false); fin_tour(); } }}); bCol3J[5].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==5) { bCol3J[5].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[5].setEnabled(false); fin_tour(); } }}); bCol3J[6].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==6) { bCol3J[6].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[6].setEnabled(false); fin_tour(); } }}); bCol3J[7].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==7) { bCol3J[7].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[7].setEnabled(false); fin_tour(); } }}); bCol3J[8].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==8) { bCol3J[8].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[8].setEnabled(false); fin_tour(); } }}); bCol3J[9].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==9) { bCol3J[9].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[9].setEnabled(false); fin_tour(); } }}); bCol3J[10].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==10) { bCol3J[10].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[10].setEnabled(false); fin_tour(); } }}); bCol3J[11].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==11) { bCol3J[11].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[11].setEnabled(false); fin_tour(); } }}); bCol3J[12].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==12) { bCol3J[12].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[12].setEnabled(false); fin_tour(); } }}); bCol3J[13].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(Monte==13) { bCol3J[13].setBackground(Color.yellow); Monte--; if(Monte==6) Monte--; bCol3J[13].setEnabled(false); fin_tour(); } }}); } public void Lance_Des(){ int temp=0; int val; lance++; lStatus[0].setText("Lance numero "+String.valueOf(lance)); for(int i=0;i<5;i++){ val = nb.nextInt(6)+1; if(Des[i]==0) { bDes[i].setLabel(String.valueOf(val)); } /* temp+=Integer.parseInt(bDes[i].getLabel()); */ temp += Integer.parseInt(bDes[i].getLabel()); } lStatus[1].setText("Total = "+String.valueOf(temp)); Score(); } public void Score(){ int vtemp; for(int i=0;i<14;i++) { if(bCol1J[i].getBackground()==Color.orange) { bCol1J[i].setLabel("0"); bCol1J[i].setBackground(Color.white); } if(bCol2J[i].getBackground()==Color.orange) { bCol2J[i].setLabel("0"); bCol2J[i].setBackground(Color.white); } if(bCol3J[i].getBackground()==Color.orange) { bCol3J[i].setLabel("0"); bCol3J[i].setBackground(Color.white); } } // 1,2,3,4,5,6 for(int j=0;j<6;j++) { vtemp=0; for(int i=0;i<5;i++) { if(Integer.parseInt(bDes[i].getLabel())==(j+1)) vtemp=vtemp+(j+1); } if((bCol1J[j].getBackground()==Color.white) && (vtemp!=0)) { bCol1J[j].setLabel(String.valueOf(vtemp)); bCol1J[j].setBackground(Color.orange); } if((bCol2J[j].getBackground()==Color.white) && (vtemp!=0) && (Descend==j)) { bCol2J[j].setLabel(String.valueOf(vtemp)); bCol2J[j].setBackground(Color.orange); } if((bCol3J[j].getBackground()==Color.white) && (vtemp!=0) && (Monte==j)) { bCol3J[j].setLabel(String.valueOf(vtemp)); bCol3J[j].setBackground(Color.orange); } } // -11 vtemp=0; for(int i=0;i<5;i++) { vtemp=vtemp+Integer.parseInt(bDes[i].getLabel()); } if((bCol1J[7].getBackground()==Color.white) && (vtemp<=11)) { bCol1J[7].setLabel("20"); bCol1J[7].setBackground(Color.orange); } if((bCol2J[7].getBackground()==Color.white) && (vtemp<=11) && (Descend==7)) { bCol2J[7].setLabel("20"); bCol2J[7].setBackground(Color.orange); } if((bCol3J[7].getBackground()==Color.white) && (vtemp<=11) && (Monte==7)) { bCol3J[7].setLabel("20"); bCol3J[7].setBackground(Color.orange); } //Petit vtemp=0; for(int i=0;i<5;i++) { vtemp+=Integer.parseInt(bDes[i].getLabel()); } if(bCol1J[8].getBackground()==Color.white) { bCol1J[8].setLabel(String.valueOf(vtemp)); bCol1J[8].setBackground(Color.orange); } if((bCol2J[8].getBackground()==Color.white) && (Descend==8)) { bCol2J[8].setLabel(String.valueOf(vtemp)); bCol2J[8].setBackground(Color.orange); } if((bCol3J[8].getBackground()==Color.white) && (vtemp<(Integer.parseInt(bCol3J[9].getLabel()))) && (Monte==8)) { bCol3J[8].setLabel(String.valueOf(vtemp)); bCol3J[8].setBackground(Color.orange); } //Grand vtemp=0; for(int i=0;i<5;i++) { vtemp+=Integer.parseInt(bDes[i].getLabel()); } if((bCol1J[9].getBackground()==Color.white) && (vtemp>(Integer.parseInt(bCol1J[8].getLabel())))) { bCol1J[9].setLabel(String.valueOf(vtemp)); bCol1J[9].setBackground(Color.orange); } if((bCol2J[9].getBackground()==Color.white) && (vtemp>(Integer.parseInt(bCol2J[8].getLabel()))) && (Descend==9)) { bCol2J[9].setLabel(String.valueOf(vtemp)); bCol2J[9].setBackground(Color.orange); } if((bCol3J[9].getBackground()==Color.white) && (Monte==9)) { bCol3J[9].setLabel(String.valueOf(vtemp)); bCol3J[9].setBackground(Color.orange); } // Carre for(int j=0;j<6;j++) { vtemp=0; for(int i=0;i<5;i++) { if(Integer.parseInt(bDes[i].getLabel())==(j+1)) vtemp=vtemp+1; } if(bCol1J[10].getBackground()==Color.white && (vtemp==4 || vtemp==5)) { bCol1J[10].setLabel(String.valueOf(30+(j+1)*4)); bCol1J[10].setBackground(Color.orange); } if(bCol2J[10].getBackground()==Color.white && (vtemp==4 || vtemp==5) && (Descend==10)) { bCol2J[10].setLabel(String.valueOf(30+(j+1)*4)); bCol2J[10].setBackground(Color.orange); } if(bCol3J[10].getBackground()==Color.white && (vtemp==4 || vtemp==5) && (Monte==10)) { bCol3J[10].setLabel(String.valueOf(30+(j+1)*4)); bCol3J[10].setBackground(Color.orange); } } // Full int s=0; int un=0; int deux=0; for(int j=0;j<6;j++) { vtemp=0; for(int i=0;i<5;i++) { if(Integer.parseInt(bDes[i].getLabel())==(j+1)) vtemp=vtemp+1; } if(vtemp==3) { un=(j+1); s++; s++; } if(vtemp==2) { deux=(j+1); s++; } if(bCol1J[11].getBackground()==Color.white && (s==3)) { bCol1J[11].setLabel(String.valueOf(40+3*un+2*deux)); bCol1J[11].setBackground(Color.orange); } if(bCol2J[11].getBackground()==Color.white && (s==3) && (Descend==11)) { bCol2J[11].setLabel(String.valueOf(40+3*un+2*deux)); bCol2J[11].setBackground(Color.orange); } if(bCol3J[11].getBackground()==Color.white && (s==3) && (Monte==11)) { bCol3J[11].setLabel(String.valueOf(40+3*un+2*deux)); bCol3J[11].setBackground(Color.orange); } } // Quinte un=0; deux=0; int trois=0; int quatre=0; int cinq=0; int six=0; for(int i=0;i<5;i++) { if(Integer.parseInt(bDes[i].getLabel())==(1)) un=1; if(Integer.parseInt(bDes[i].getLabel())==(2)) deux=1; if(Integer.parseInt(bDes[i].getLabel())==(3)) trois=1; if(Integer.parseInt(bDes[i].getLabel())==(4)) quatre=1; if(Integer.parseInt(bDes[i].getLabel())==(5)) cinq=1; if(Integer.parseInt(bDes[i].getLabel())==(6)) six=1; } if((bCol1J[12].getBackground()==Color.white) && (un==1) && (deux==1) && (trois==1) && (quatre==1) && (cinq==1)) { bCol1J[12].setLabel(String.valueOf(65)); bCol1J[12].setBackground(Color.orange); } if((bCol2J[12].getBackground()==Color.white) && (un==1) && (deux==1) && (trois==1) && (quatre==1) && (cinq==1) && (Descend==12)) { bCol2J[12].setLabel(String.valueOf(65)); bCol2J[12].setBackground(Color.orange); } if((bCol3J[12].getBackground()==Color.white) && (un==1) && (deux==1) && (trois==1) && (quatre==1) && (cinq==1) && (Monte==12)) { bCol3J[12].setLabel(String.valueOf(65)); bCol3J[12].setBackground(Color.orange); } if((bCol1J[12].getBackground()==Color.white) && (six==1) && (deux==1) && (trois==1) && (quatre==1) && (cinq==1)) { bCol1J[12].setLabel(String.valueOf(70)); bCol1J[12].setBackground(Color.orange); } if((bCol2J[12].getBackground()==Color.white) && (six==1) && (deux==1) && (trois==1) && (quatre==1) && (cinq==1) && (Descend==12)) { bCol2J[12].setLabel(String.valueOf(70)); bCol2J[12].setBackground(Color.orange); } if((bCol3J[12].getBackground()==Color.white) && (six==1) && (deux==1) && (trois==1) && (quatre==1) && (cinq==1) && (Monte==12)) { bCol3J[12].setLabel(String.valueOf(70)); bCol3J[12].setBackground(Color.orange); } // Yams for(int j=0;j<6;j++) { vtemp=0; for(int i=0;i<5;i++) { if(Integer.parseInt(bDes[i].getLabel())==(j+1)) vtemp=vtemp+1; } if((bCol1J[13].getBackground()==Color.white) && (vtemp==5)) { bCol1J[13].setLabel(String.valueOf(60+(j+1)*5)); bCol1J[13].setBackground(Color.orange); } if((bCol2J[13].getBackground()==Color.white) && (vtemp==5) && (Descend==13)) { bCol2J[13].setLabel(String.valueOf(60+(j+1)*5)); bCol2J[13].setBackground(Color.orange); } if((bCol3J[13].getBackground()==Color.white) && (vtemp==5) && (Monte==13)) { bCol3J[13].setLabel(String.valueOf(60+(j+1)*5)); bCol3J[13].setBackground(Color.orange); } } } public void Total(){ int temp; Col1J[14]=0; Col2J[14]=0; Col3J[14]=0; // + 30 temp=0; for(int i=0;i<6;i++) { temp+=Integer.parseInt(bCol1J[i].getLabel()); } if(temp>=60) { bCol1J[6].setLabel("30"); bCol1J[6].setBackground(Color.yellow); } temp=0; for(int i=0;i<6;i++) { temp+=Integer.parseInt(bCol2J[i].getLabel()); } if(temp>=60) { bCol2J[6].setLabel("30"); bCol2J[6].setBackground(Color.yellow); } temp=0; for(int i=0;i<6;i++) { temp+=Integer.parseInt(bCol3J[i].getLabel()); } if(temp>=60) { bCol3J[6].setLabel("30"); bCol3J[6].setBackground(Color.yellow); } //Total for(int i=0;i<14;i++) { if(bCol1J[i].getLabel()!="0"){ Col1J[i]=Integer.parseInt(bCol1J[i].getLabel()); Col1J[14]+=Col1J[i];} if(bCol2J[i].getLabel()!="0"){ Col2J[i]=Integer.parseInt(bCol2J[i].getLabel()); Col2J[14]+=Col2J[i];} if(bCol3J[i].getLabel()!="0"){ Col3J[i]=Integer.parseInt(bCol3J[i].getLabel()); Col3J[14]+=Col3J[i];} } bCol1J[14].setLabel(String.valueOf(Col1J[14])); bCol2J[14].setLabel(String.valueOf(Col2J[14])); bCol3J[14].setLabel(String.valueOf(Col3J[14])); ttJ=Integer.parseInt(bCol1J[14].getLabel())+Integer.parseInt(bCol2J[14].getLabel())+Integer.parseInt(bCol3J[14].getLabel()); lHighScore[14].setText(String.valueOf(ttJ)); } public void fin_tour(){ lance=0; joue++; for(int i=0;i<14;i++) { if(bCol1J[i].getBackground()==Color.orange) { bCol1J[i].setLabel("0"); bCol1J[i].setBackground(Color.white); } if(bCol2J[i].getBackground()==Color.orange) { bCol2J[i].setLabel("0"); bCol2J[i].setBackground(Color.white); } if(bCol3J[i].getBackground()==Color.orange) { bCol3J[i].setLabel("0"); bCol3J[i].setBackground(Color.white); } } Total(); if(joue==39)//39 { bButtons[1].setEnabled(true); bButtons[0].setEnabled(false); lStatus[0].setText("Partie finie : "+String.valueOf(ttJ)); } else { lStatus[0].setText("Vous pouvez relancer !"); for(int i=0;i<5;i++){ bDes[i].setBackground(Color.white); Des[i]=0;} } } public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals(bButtons[4])) { System.exit(0);; } } }
Tout compiler avec :
javac -deprecation Yams.java
Enfin créer une page html pour l’exploiter :
<html> <body> <center><applet code="Yams.class" width=500 height=400 alt="Yams"> Yams</applet></center> </body> </html>