-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIHM.java
More file actions
117 lines (91 loc) · 3.4 KB
/
IHM.java
File metadata and controls
117 lines (91 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package Ui;
import Util.Messages;
import Util.Utilitaire;
import java.util.ArrayList;
import java.util.Observable;
import java.util.Scanner;
public class IHM extends Observable{
private ArrayList<String> nomJoueurs;
public IHM(){
this.setNomJoueurs(new ArrayList<>());
}
public void message(String texte){
System.out.println(texte);
}
public void afficheMenu(){
System.out.println("+------------------------------+");
System.out.println("| 1. Inscrire les joueurs |");
System.out.println("| 2. Commencer le jeu |");
System.out.println("| 3. Quitter |");
System.out.println("+------------------------------+");
System.out.println("");
int choix = 0;
System.out.println("Choisir une option:");
Scanner sc = new Scanner(System.in);
choix = sc.nextInt();
while(choix!=1 && choix!=2 && choix!=3){
System.out.println("Saisie incorrecte, veuillez recommencer. (1,2 ou 3)");
choix = sc.nextInt();
}
System.out.println("");
switch (choix) {
case 1:
setChanged();
notifyObservers(Messages.INSCRIRE_JOUEURS);
clearChanged();
break;
case 2:
setChanged();
notifyObservers(Messages.COMMENCER_JEU);
clearChanged();
break;
default:
setChanged();
notifyObservers(Messages.QUITTER);
clearChanged();
break;
}
}
public void inscriptionJoueurs(){
int nbJoueurs = 0;
boolean continuer = true;
String choix ="";
Scanner sc = new Scanner(System.in);
System.out.println("Entrez les noms des joueurs un par ligne, caractère blanc pour finir :");
while(nbJoueurs <6 && continuer){
choix = sc.next();
getNomJoueurs().add(choix);
nbJoueurs++;
if (choix.equalsIgnoreCase("")){
if(nbJoueurs >=2){
continuer = false;
}else{
System.out.println("Pas assez de joueurs pour continuer.(2 minimum)");
}
}
}
setChanged();
notifyObservers(Messages.INSCRIRE_FIN);
clearChanged();
}
public void jouerTour(){
}
public void message(int aType, String aNomProp, int aPrix) {
throw new UnsupportedOperationException();
}
public void message(int aType, String aNomProp, int aLoyer, int aCash) {
throw new UnsupportedOperationException();
}
public void message(int aType, String aNomProp) {
throw new UnsupportedOperationException();
}
private void notifierObservateurs() {
throw new UnsupportedOperationException();
}
public ArrayList<String> getNomJoueurs() {
return nomJoueurs;
}
private void setNomJoueurs(ArrayList<String> nomJoueurs) {
this.nomJoueurs = nomJoueurs;
}
}