-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFighter.java
More file actions
35 lines (29 loc) · 898 Bytes
/
Fighter.java
File metadata and controls
35 lines (29 loc) · 898 Bytes
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
public class Fighter {
String name;
int weight;
int health;
int damage;
int block;
Fighter(String name, int weight, int health, int damage, int block) {
this.name = name;
this.weight = weight;
this.health = health;
this.damage = damage;
this.block = block;
}
public int attack(Fighter foe) { //foe "rakip" demek
int actualDamage = this.damage - foe.block; // block hasarı azaltır
if (actualDamage < 0) {
actualDamage = 0; // negatif hasar olmasın
foe.health -= actualDamage;
System.out.println(this.name + " attacks " + foe.name + " for " + actualDamage + " damage!");
}
return 0;
}
boolean isWin() {
return this.health > 0;
}
void printStatus() {
System.out.println(this.name + " | Health: " + this.health);
}
}