diff --git a/.vscode/configurationCache.log b/.vscode/configurationCache.log new file mode 100644 index 0000000..74f0781 --- /dev/null +++ b/.vscode/configurationCache.log @@ -0,0 +1 @@ +{"buildTargets":["Case.class","but","clean","main_ex.class","observateurButtonEtText.class","observateurCase.class","observateurChoix.class","observateurFenetre.class","observateurSAV.class","paintChoix.class","paintMenuJeu.class","plateau.class","plusoumoins.class","run"],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}} \ No newline at end of file diff --git a/.vscode/dryrun.log b/.vscode/dryrun.log new file mode 100644 index 0000000..2905db7 --- /dev/null +++ b/.vscode/dryrun.log @@ -0,0 +1,17 @@ +make --dry-run --always-make --keep-going --print-directory +make: Entering directory `/Users/tommonin/Documents/SAE21_2021' +javac -implicit:none Case.java + +javac -implicit:none plateau.java +javac -implicit:none observateurCase.java +javac -implicit:none paintMenuJeu.java +javac -implicit:none observateurSAV.java +javac -implicit:none observateurFenetre.java +javac -implicit:none paintChoix.java +javac -implicit:none observateurChoix.java + +javac -implicit:none plusoumoins.java +javac -implicit:none observateurButtonEtText.java +javac -implicit:none main_ex.java +make: Leaving directory `/Users/tommonin/Documents/SAE21_2021' + diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..65e1ec0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "makefile.extensionOutputFolder": "./.vscode" +} \ No newline at end of file diff --git a/.vscode/targets.log b/.vscode/targets.log new file mode 100644 index 0000000..422eb40 --- /dev/null +++ b/.vscode/targets.log @@ -0,0 +1,410 @@ +make all --print-data-base --no-builtin-variables --no-builtin-rules --question +# GNU Make 3.81 +# Copyright (C) 2006 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. +# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# This program built for i386-apple-darwin11.3.0 + +# Make data base, printed on Wed May 11 20:30:49 2022 + +# Variables + +# automatic +/dev/null || echo /Developer)/Makefiles +# environment +VSCODE_CODE_CACHE_PATH = /Users/tommonin/Library/Application Support/Code/CachedData/da15b6fd3ef856477bf6f4fb29ba1b7af717770d +# environment +LOGNAME = tommonin +# environment +APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL = 1 +# environment +ZSH = /Users/tommonin/.oh-my-zsh +# environment +VSCODE_HANDLES_UNCAUGHT_ERRORS = true +# automatic +^D = $(patsubst %/,%,$(dir $^)) +# environment +XPC_FLAGS = 0x0 +# default +MAKE = $(MAKE_COMMAND) +# default +MAKECMDGOALS := all +# environment +SHLVL = 1 +# default +MAKE_VERSION := 3.81 +# environment +USER = tommonin +# makefile +.DEFAULT_GOAL := but +# environment +LESS = -R +# automatic +%D = $(patsubst %/,%,$(dir $%)) +# default +MAKE_COMMAND := /Library/Developer/CommandLineTools/usr/bin/make +# default +.VARIABLES := +# environment +TMPDIR = /var/folders/z7/5ldy4cvx299dqsp97x3f2vj80000gn/T/ +# automatic +*F = $(notdir $*) +# environment +VSCODE_IPC_HOOK = /Users/tommonin/Library/Application Support/Code/1.67.1-main.sock +# makefile +MAKEFLAGS = Rrqp +# environment +MFLAGS = -Rrqp +# automatic +*D = $(patsubst %/,%,$(dir $*)) +# environment +XPC_SERVICE_NAME = application.com.microsoft.VSCode.23049971.23049977 +# environment +HOMEBREW_PREFIX = /opt/homebrew +# automatic ++D = $(patsubst %/,%,$(dir $+)) +# automatic ++F = $(notdir $+) +# environment +HOMEBREW_REPOSITORY = /opt/homebrew +# environment +__CF_USER_TEXT_ENCODING = 0x1F5:0x0:0x1 +# environment +COMMAND_MODE = unix2003 +# default +MAKEFILES := +# automatic +this.plat.getLigne()*this.plat.getCollonne()){ + nombre=this.plat.getLigne()*this.plat.getCollonne(); + } + this.plat.setBombe(nombre); + if(this.plat.getLigne()!=-1 && this.plat.getCollonne()!=-1 && this.plat.getBombe()!=-1){ + this.plat.newGame(); + }else{ + if(this.plat.getBombe()==-1){ + this.zone.setBackground(Color.red); + this.zone.setText("Rentrer un nombre de Bobme"); + } + } + }else{ + this.zone.setBackground(Color.red); + this.zone.setText("Selectionner Ligne et Collonne Avant"); + this.plat.setBombe(-1); + } + this.plat.setBombe(nombre); + }catch(NumberFormatException e1){ + this.zone.setBackground(Color.red); + this.zone.setText("rentrer un nombre valide"); + this.plat.setBombe(-1); } } if(this.fonction==3){ diff --git a/paintMenuJeu.java b/paintMenuJeu.java index 0739021..f831302 100644 --- a/paintMenuJeu.java +++ b/paintMenuJeu.java @@ -5,27 +5,11 @@ import javax.swing.JComponent; public class paintMenuJeu extends JComponent{ private int choix; private int scoreMax, score; - private Image un, deux, trois, quatre, cinq, six, sept, huit, neuf, zero, err, sav, lose, win, replay; private boolean survol; public paintMenuJeu(int choix0, int score0, int scoreMax0){ this.choix=choix0; this.score=score0; this.scoreMax=scoreMax0; - this.un=Toolkit.getDefaultToolkit().getImage("./IMAGE/unD.png"); - this.deux=Toolkit.getDefaultToolkit().getImage("./IMAGE/deuxD.png"); - this.trois=Toolkit.getDefaultToolkit().getImage("./IMAGE/troisD.png"); - this.quatre=Toolkit.getDefaultToolkit().getImage("./IMAGE/quatreD.png"); - this.cinq=Toolkit.getDefaultToolkit().getImage("./IMAGE/cinqD.png"); - this.six=Toolkit.getDefaultToolkit().getImage("./IMAGE/sixD.png"); - this.sept=Toolkit.getDefaultToolkit().getImage("./IMAGE/septD.png"); - this.huit=Toolkit.getDefaultToolkit().getImage("./IMAGE/huitD.png"); - this.neuf=Toolkit.getDefaultToolkit().getImage("./IMAGE/neufD.png"); - this.zero=Toolkit.getDefaultToolkit().getImage("./IMAGE/zeroD.png"); - this.err=Toolkit.getDefaultToolkit().getImage("./IMAGE/err.png"); - this.sav=Toolkit.getDefaultToolkit().getImage("./IMAGE/sav.png"); - this.lose=Toolkit.getDefaultToolkit().getImage("./IMAGE/lose.png"); - this.win=Toolkit.getDefaultToolkit().getImage("./IMAGE/win.png"); - this.replay=Toolkit.getDefaultToolkit().getImage("./IMAGE/replay.png"); this.survol=false; } public void setChoix(int choix0){ @@ -86,56 +70,71 @@ public class paintMenuJeu extends JComponent{ secondPinceau.setColor(new Color(0,255,0)); secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); } - secondPinceau.drawImage(this.sav, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image sav=Toolkit.getDefaultToolkit().getImage("./IMAGE/sav.png"); + secondPinceau.drawImage(sav, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(this.choix==5){ - secondPinceau.drawImage(this.lose, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image lose=Toolkit.getDefaultToolkit().getImage("./IMAGE/lose.png"); + secondPinceau.drawImage(lose, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(this.choix==6){ - secondPinceau.drawImage(this.win, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image win=Toolkit.getDefaultToolkit().getImage("./IMAGE/win.png"); + secondPinceau.drawImage(win, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(this.choix==7){ if(this.survol==true){ secondPinceau.setColor(new Color(0,255,0)); secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); } - secondPinceau.drawImage(this.replay, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image replay=Toolkit.getDefaultToolkit().getImage("./IMAGE/replay.png"); + secondPinceau.drawImage(replay, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } } private void paintNombre(Graphics secondPinceau, int nombre){ if(this.score>=0){ if(nombre==1){ - secondPinceau.drawImage(this.un, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image un=Toolkit.getDefaultToolkit().getImage("./IMAGE/unD.png"); + secondPinceau.drawImage(un, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(nombre==2){ - secondPinceau.drawImage(this.deux, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image deux=Toolkit.getDefaultToolkit().getImage("./IMAGE/deuxD.png"); + secondPinceau.drawImage(deux, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(nombre==3){ - secondPinceau.drawImage(this.trois, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image trois=Toolkit.getDefaultToolkit().getImage("./IMAGE/troisD.png"); + secondPinceau.drawImage(trois, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(nombre==4){ - secondPinceau.drawImage(this.quatre, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image quatre=Toolkit.getDefaultToolkit().getImage("./IMAGE/quatreD.png"); + secondPinceau.drawImage(quatre, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(nombre==5){ - secondPinceau.drawImage(this.cinq, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image cinq=Toolkit.getDefaultToolkit().getImage("./IMAGE/cinqD.png"); + secondPinceau.drawImage(cinq, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(nombre==6){ - secondPinceau.drawImage(this.six, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image six=Toolkit.getDefaultToolkit().getImage("./IMAGE/sixD.png"); + secondPinceau.drawImage(six, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(nombre==7){ - secondPinceau.drawImage(this.sept, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image sept=Toolkit.getDefaultToolkit().getImage("./IMAGE/septD.png"); + secondPinceau.drawImage(sept, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(nombre==8){ - secondPinceau.drawImage(this.huit, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image huit=Toolkit.getDefaultToolkit().getImage("./IMAGE/huitD.png"); + secondPinceau.drawImage(huit, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(nombre==9){ - secondPinceau.drawImage(this.neuf, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image neuf=Toolkit.getDefaultToolkit().getImage("./IMAGE/neufD.png"); + secondPinceau.drawImage(neuf, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } if(nombre==0){ - secondPinceau.drawImage(this.zero, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image zero=Toolkit.getDefaultToolkit().getImage("./IMAGE/zeroD.png"); + secondPinceau.drawImage(zero, this.getWidth()/6, this.getHeight()/6, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } }else{ - secondPinceau.drawImage(this.err, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/6*4, this.getHeight()/6*4 ,this); + Image err=Toolkit.getDefaultToolkit().getImage("./IMAGE/err.png"); + secondPinceau.drawImage(err, this.getWidth()/20*5, this.getHeight()/20*5, this.getWidth()/6*4, this.getHeight()/6*4 ,this); } } diff --git a/plateau.java b/plateau.java index 06ebae4..ac27937 100644 --- a/plateau.java +++ b/plateau.java @@ -20,8 +20,9 @@ public class plateau{ this.fenetre=fenetre0; this.ligne=-1; this.collonne=-1; - this.bombe=0; + this.bombe=-1; } + //-------------------> Debut Seter et Getteur <------------------------- public void setLogo(paintMenuJeu logo0){ this.logo=logo0; } @@ -49,6 +50,8 @@ public class plateau{ public void setBombe(int n){ this.bombe=n; } + //-------------------------> fin Setter et Getteur <----------------------------- + //-------------------------Fonction plaçant les bombes aléatoirement------------------------ private void setAllBombe(){ @@ -227,7 +230,7 @@ public class plateau{ for(int i=0; i Fonction pour sauvegarder la partie <------------------------- +/* + +Mettre les bloc try catch au bon endroit +*/ + + + public void save(){ //les fonctions vont lever des Exeption nous devons donc mettre un try Catch try{ //nous initialison le outputStream en créant le fichier "sauvegarde.data" FileOutputStream sav = new FileOutputStream(new File("sauvegarde.data")); - //nous allons sérialiser le tableau de Case - ObjectOutputStream oos = new ObjectOutputStream(sav); - //nous écrivons donc tout d'abord la taille de celui-ci - oos.writeInt(this.ligne); - oos.writeInt(this.collonne); - //puis nous parcourons le tableau en sérialisant toute les Case - for(int i=0; i