Repository navigation
Expand file tree
/
Copy pathTrainer.java
More file actions
64 lines (54 loc) · 1.87 KB
/
Copy pathTrainer.java
File metadata and controls
64 lines (54 loc) · 1.87 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
import java.util.Scanner;
class Trainer extends Characters implements Recovery {
Scanner scan = new Scanner(System.in);
private Monster monster = new Monster();
private boolean isAdventure;
public Monster getMonster () {
return this.monster;
}
public void setInfo () {
System.out.println("あなたの名前は何ですか?");
String name = scan.next();
setName(name);
monster.setInfo();
}
public void printTrainer () {
System.out.println("----------");
System.out.println("[トレーナー情報]");
System.out.println("名前 : " + getName() + ", Level : " + getLevel());
monster.printMonster();
System.out.println();
System.out.println("----------");
System.out.println();
}
public void setIsAdventure () {
Scanner scan = new Scanner(System.in);
System.out.println("冒険に出かけますか?( yes / no )");
String isAdventure = scan.next();
if (!isAdventure.equals("yes")) {
System.out.println(getName() + " は、静かに家路についた。");
this.isAdventure = false;
return;
}
if (monster.getHp() == 0) {
this.recovery();
}
System.out.println();
System.out.println("==========");
System.out.println(getName() + " は、冒険に出かけた。");
System.out.println("==========");
System.out.println();
this.isAdventure = true;
}
public boolean getIsAdventure () {
return this.isAdventure;
};
public void recovery () {
monster.setHp(100);
System.out.println();
System.out.println("==========");
System.out.println(monster.getName() + "のHPは回復した。");
System.out.println("==========");
System.out.println();
};
}