forked from laboon/deliverable2_repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.java
86 lines (72 loc) · 2.14 KB
/
Player.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
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
package com.laboon;
public class Player {
private boolean _hasSugar = false;
private boolean _hasCream = false;
private boolean _hasCoffee = false;
public Player() {
}
public Player(boolean sugar, boolean cream, boolean coffee) {
_hasSugar = sugar;
_hasCream = cream;
_hasCoffee = coffee;
}
public void getSugar() {
System.out.println("You found some sweet sugar!");
_hasSugar = true;
}
public void getCream() {
System.out.println("You found some creamy cream!");
_hasCream = true;
}
public void getCoffee() {
System.out.println("You found some caffeinated coffee!");
_hasCoffee = true;
}
public boolean hasAllItems() {
return (_hasCoffee && _hasCream && _hasSugar);
}
public void showInventory() {
if (_hasCoffee) {
System.out.println("You have a cup of delicious coffee.");
} else {
System.out.println("YOU HAVE NO COFFEE!");
}
if (_hasCream) {
System.out.println("You have some fresh cream.");
} else {
System.out.println("YOU HAVE NO CREAM!");
}
if (_hasSugar) {
System.out.println("You have some tasty sugar.");
} else {
System.out.println("YOU HAVE NO SUGAR!");
}
}
public boolean drink() {
boolean win = false;
showInventory();
System.out.println();
if (_hasCoffee && _hasCream && _hasSugar) {
System.out.println("You drink the beverage and are ready to study!");
win = true;
} else if (_hasCoffee) {
if (!_hasCream) {
System.out.println("Without cream, you get an ulcer and cannot study.");
} else {
System.out.println("Without sugar, the coffee is too bitter. You cannot study.");
}
} else if (_hasCream) {
if (!_hasSugar) {
System.out.println("You drink the cream, but without caffeine, you cannot study.");
} else {
System.out.println("You drink the sweetened cream, but without caffeine, you cannot study.");
}
} else if (_hasSugar) {
System.out.println("You eat the sugar, but without caffeine, you cannot study.");
} else {
System.out.println("You drink the air, as you have no coffee, sugar, or cream.\n"
+ "The air is invigorating, but not invigorating enough. You cannot study.");
}
return win;
}
}