-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFighter.java
57 lines (45 loc) · 1.33 KB
/
Fighter.java
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
package java101;
public class Fighter {
String name;
int damage;
int health;
int weight;
int dodge;
int sans;
Fighter(String name, int damage, int health, int weight, int dodge,int sans ) {
this.damage = damage;
this.health = health;
this.name = name;
this.weight = weight;
if (dodge >= 0 && dodge <= 100) {
this.dodge = dodge;
} else {
this.dodge = 0;
}
if (sans >= 0 && sans <= 100) {
this.sans = sans;
} else {
this.sans = 0;
}
}
int hit(Fighter foe) {
System.out.println(this.name + "=>" + foe.name + " " + this.damage + "hasar vurdu.");
if (foe.issDodge()) {
System.out.println(foe.name + " gelen hasarı blokladı.");
System.out.println("----------------------");
return foe.health;
}
if (foe.health - this.damage < 0) {
return 0;
}
return foe.health - this.damage;
}
boolean issDodge() {
double randomNumber = Math.random() * 100;
return randomNumber <= this.dodge;
}
boolean issPass() {
double randomNumberr = Math.random() * 100;
return randomNumberr <= this.sans;
}
}