This repository was archived by the owner on Feb 5, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenc.java
More file actions
77 lines (62 loc) · 1.72 KB
/
Copy pathenc.java
File metadata and controls
77 lines (62 loc) · 1.72 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
package OOP_exc;
import java.util.Scanner;
class Karakter {
private String name;
private int level;
private int health;
private int attack;
Karakter(String name, int level, int health, int attack) {
this.name = name;
this.level = level;
this.health = health;
this.attack = attack;
}
void getName() {
System.out.println(this.name);
}
String setName(String name) {
this.name = name;
return name;
}
void getLevel() {
System.out.println(this.level);
}
int setLevel(int level) {
this.level = level;
return this.level;
}
void getHealth() {
System.out.println(this.name + " health : " + this.health);
}
int setHealth(int health) {
this.health = health;
return this.health;
}
void getAttack() {
System.out.println(this.attack);
}
int setAttack(int attack) {
this.attack = attack;
return this.attack;
}
void opponentAttack(Karakter opponent) {
System.out.println("Attacking " + opponent.name);
opponent.health -= this.attack;
}
void stats() {
System.out.println("Name\t: " + this.name);
System.out.println("Level\t: " + this.level);
System.out.println("Health\t: " + this.health);
System.out.println("Attack\t: " + this.attack);
}
}
public class enc {
public static void main(String[] args) {
// Scanner inputUser = new Scanner(System.in);
Karakter freya = new Karakter("Nimus", 1, 100, 12);
Karakter ludwik = new Karakter("Greek", 1, 100, 14);
freya.opponentAttack(ludwik);
freya.getAttack();
ludwik.getHealth();
}
}