bonjour j'aurais besoin des talents d'un d'entre vous pour finir mon exercice en java s'il vous plait.

Nom : Capture.PNG
Affichages : 180
Taille : 6,0 Ko

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
abstract class Pochemon {
	String name;
	int hpmax;
	int hp;
	int atk;
	int def;
	int vitesse;
	int xp;
 
	Pochemon(String Name, int HP, int ATK, int DEF, int SPEED, int XP){
		name=Name;
		hpmax=HP;
		hp=HP;
		atk=ATK;
		def=DEF;
		vitesse=SPEED;
		xp=XP;
 
	}
 
	Pochemon(){
		name="";
		hpmax=0;
		hp=0;
		atk=0;
	}
 
	void affiche(){
		System.out.println("Name="+name);
		System.out.println("Hp="+hp+"/"+hpmax);
		System.out.println("Atk="+atk);
		System.out.println("def="+def);
		System.out.println("speed="+vitesse);
		System.out.println("experience="+xp);
	}
 
	void changehp(int n){
		hp=hp+n;
		if (hp>hpmax){
			hp=hpmax;
		}
		if(hp<0){
			hp=0;
			System.out.println(name+" is KO");
		}
	}
	void fullrest(){
		changehp(hpmax);
	}
	boolean mort(){
		return (hp==0);
	}
 
	abstract void attaquer(Pochemon cible);
 
	void combat (Pochemon cible){
		int turn = 0;
		System.out.println(name+" challenges "+cible.name);
		while(!mort() && !cible.mort()){
			if (turn%2==0){
				attaquer(cible);
			}
			else{
				cible.attaquer(this);
			}
			turn=turn+1;
		}
		if (mort()){
			System.out.println(cible.name+ " beat "+name+" in "+turn+" turns");
		}
		else{
			System.out.println(name+ " beat "+cible.name+" in "+turn+" turns");
		}			
	}
}
 
class Chaleur extends Pochemon{
	Chaleur(String Name, int HP, int ATK, int DEF, int SPEED, int XP){
		super(Name,HP,ATK,DEF,SPEED,XP);
	}
	Chaleur(){
		super();
	}
 
	void affiche(){
		System.out.println("Type=Chaleur");
		super.affiche();
	}
	void attaquer(Pochemon cible){
		if (! mort()){
			if (cible instanceof Herbe){
				cible.changehp(-2*atk);
			}
			else if (cible instanceof Pluie){
				cible.changehp(-atk/2);
			}
			else{
				cible.changehp(-atk);
			}
		}
	}
}	
 
 
class Herbe extends Pochemon{
	Herbe(String Name, int HP, int ATK, int DEF, int SPEED, int XP){
		super(Name,HP,ATK,DEF,SPEED,XP);
	}
	Herbe(){
		super();
	}
 
	void affiche(){
		System.out.println("Type=Herbe");
		super.affiche();
	}
	void attaquer(Pochemon cible){
		if (! mort()){
			if (cible instanceof Pluie){
				cible.changehp(-2*atk);
			}
			else if (cible instanceof Chaleur){
				cible.changehp(-atk/2);
			}
			else{
				cible.changehp(-atk);
			}
		}
	}
}
 
 
class Pluie extends Pochemon{
	Pluie(String Name, int HP, int ATK, int DEF, int SPEED, int XP){
		super(Name,HP,ATK,DEF,SPEED,XP);
	}
	Pluie(){
		super();
	}
 
	void affiche(){
		System.out.println("Type=Pluie");
		super.affiche();
	}
	void attaquer(Pochemon cible){
		if (! mort()){
			if (cible instanceof Chaleur){
				cible.changehp(-2*atk);
			}
			else if (cible instanceof Herbe){
				cible.changehp(-atk/2);
			}
			else{
				cible.changehp(-atk);
			}
		}
	}
}
 
 
class Standard extends Pochemon{
	Standard(String Name, int HP, int ATK, int DEF, int SPEED, int XP){
		super(Name,HP,ATK,DEF,SPEED,XP);
	}
	Standard(){
		super();
	}
 
	void affiche(){
		System.out.println("Type=Standard");
		super.affiche();
	}
	void attaquer(Pochemon cible){
		if (! mort()){
			cible.changehp(-atk);
		}
	}
}
class Pierre extends Pochemon{
	Pierre(String Name, int HP, int ATK, int DEF, int SPEED, int XP){
		super(Name,HP,ATK,DEF,SPEED,XP);
	}
	Pierre(){
		super();
	}
 
	void affiche(){
		System.out.println("Type=Pierre");
		super.affiche();
	}
	void attaquer(Pochemon cible){
		if (! mort()){
			if (cible instanceof Herbe){
				cible.changehp(-3*atk);
			}
			else if (cible instanceof Pluie){
				cible.changehp(-atk/2);
			}
			else{
				cible.changehp(-atk);
			}
		}
	}
}
 
class Enfer extends Pochemon{
	Enfer(String Name, int HP, int ATK, int DEF, int SPEED, int XP){
		super(Name,HP,ATK,DEF,SPEED,XP);
	}
	Enfer(){
		super();
	}
 
	void affiche(){
		System.out.println("Type=Enfer");
		super.affiche();
	}
	void attaquer(Pochemon cible){
		if (! mort()){
			if (cible instanceof Herbe){
				cible.changehp(-5*atk);
			}
			else if (cible instanceof Pierre){
				cible.changehp(-atk/3);
			}
			else{
				cible.changehp(2*-atk);
			}
		}
	}
}
 
public class Arena{
 
	public static void main(String args[]){
		Chaleur p1 = new Chaleur("Fireguy",100,60,50,40,10);
		Pluie p2 = new Pluie("Waterguy",400,15,40,60,10);
		Herbe p3 = new Herbe("Plantguy",200,30,30,20,10);
		Standard p4 = new Standard("Boringguy",100,15,50,30,10);
		Pierre p5 = new Pierre("Yvesrocher",600,40,100,10,10);
		Enfer p6 =new Enfer("Satan",100,70,50,100,10);
		p1.affiche();
		p2.affiche();
		p3.affiche();
		p4.affiche();
		p5.affiche();
		p6.affiche();
		System.out.println();
		p1.combat(p2);
		p1.fullrest();
		p2.fullrest();
		p2.combat(p3);
		p5.combat(p4);
		p5.fullrest();
		p6.combat(p5);
		p6.fullrest();
		p6.combat(p2);
		p6.fullrest();
 
	}
 
}
je vous remercie d'avance pour vos réponses.

PS: c'est pour vendredi 12 mars