-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
65 lines (58 loc) · 2.66 KB
/
Copy pathMain.java
File metadata and controls
65 lines (58 loc) · 2.66 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
import java.util.Scanner;
public class Main {
// Booleans for Phases
static Boolean shopping = true;
static Boolean waiting = false;
public static void main(String[] args) {
Scanner currentSessionScanner = new Scanner(System.in);
String name = currentSessionScanner.nextLine();
System.out.println("Hello " + name + ", welcome to some game i guess");
Player player = new Player();
player.player(name);
System.out.println("Here is a shop, here are the items");
Shop thisShop = new Shop();
thisShop.shop();
thisShop.printItemList();
while (shopping) {
System.out.println("Would you like to buy something? (Type Y for yes and N for no)");
String input = currentSessionScanner.nextLine();
switch (input) {
case "Y":
System.out.println("Please type in the index of the item you wish to buy (in between " + 0 + " and "
+ (thisShop.itemList.size() - 1) + ")");
int itemIndexToBuy = currentSessionScanner.nextInt();
thisShop.buyItem(player, itemIndexToBuy);
// This consumes the next dummy line, such that it doesnt print the default case
// automatically
String dummy = currentSessionScanner.nextLine();
break;
case "N":
System.out.println("Have a nice day");
shopping = false;
break;
default:
System.out.println("INPUT IS :" + input);
System.out.println("Please type in either Y or N please");
break;
}
waiting = true;
}
System.out.println("Now we are in the \"what do i do now\" phase");
System.out.println(
"You can go and fight monsters (type: FIGHT), check your inventory (type: INVENTORY), or hug your mom (type: HUG), or exit the game (type: EXIT) ");
while (waiting) {
String action = currentSessionScanner.nextLine();
if (action.equals("FIGHT")) {
System.out.println("You went to fight a monster");
} else if (action.equals("INVENTORY")) {
player.printInventoryItems();
} else if (action.equals("HUG")) {
System.out.println("You went to hug a tree. Thats weird, your mom is not a tree.");
} else if (action.equals("EXIT")) {
System.out.println("Bye traveller");
break;
}
}
currentSessionScanner.close();
}
}