/** * @(#)ComBuster.java * * ComBuster application * * @author * @version 1.00 2007/12/22 */ import java.util.*; public class ComBuster { private GameHelper helper = new GameHelper(); private ArrayList listePointComs = new ArrayList(); private int nbPropo = 0; /****************************************************************************************/ private void installerJeu(){ PointCom Un = new PointCom(); PointCom Deux = new PointCom(); PointCom Trois = new PointCom(); Un.setNom("Go2.Com"); Deux.setNom("Cast.Com"); Trois.setNom("Askme.Com"); listePointComs.add(Un); listePointComs.add(Deux); listePointComs.add(Trois); System.out.println("votre but est de couler trois pointcoms."); System.out.println("Go2.Com, Cast.Com,Askme.Com."); System.out.println("Essayez de les couler en un minimum de coups."); for(int i=0; i<= listePointComs.size(); i++){ ArrayList nouvellePlace = helper.placePointCom(3); PointCom pointComAPlacer = (PointCom)listePointComs.get(i); pointComAPlacer.setCellules(nouvellePlace); } } void commencerJeu(){ while (!listePointComs.isEmpty()){ String propoUtil = helper.getUserInput("coordonnées ? "); testerPropoUtil(propoUtil); } terminerJeu(); } void testerPropoUtil(String propoUtil){ nbPropo++; String resultat = "manqué"; for(int i =0; i<= listePointComs.size(); i++) { PointCom pointComATester = (PointCom) listePointComs.get(i); resultat = pointComATester.autoVerif(propoUtil); if (resultat.equals("Coulé")){ //System.out.println("le PointCom " + pointComATester.Nom + " est Coulé"); listePointComs.remove(i); break; } } System.out.println("le resultat est " + resultat); } void terminerJeu() { System.out.println("Tout les pointCom sont mort le jeu est terminer."); if(nbPropo <= 18){ System.out.println("il ne vous fallu que "+ nbPropo + " coups."); System.out.println("vous vous êtes sorti a temps."); } else { System.out.println("Trop long. "+ nbPropo + " coups."); System.out.println("les poissons dévorent vos stock options."); } } public static void main(String[] args) { ComBuster jeu = new ComBuster(); jeu.installerJeu(); jeu.commencerJeu(); } }