Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/Avatar.class
Binary file not shown.
Binary file added src/Backpack.class
Binary file not shown.
Binary file added src/Book.class
Binary file not shown.
Binary file added src/BuildWorld.class
Binary file not shown.
Binary file added src/Course.class
Binary file not shown.
Binary file added src/Creature.class
Binary file not shown.
Binary file added src/EmptyFileException.class
Binary file not shown.
Binary file added src/Item.class
Binary file not shown.
Binary file added src/Key.class
Binary file not shown.
Binary file added src/ListToString.class
Binary file not shown.
Binary file added src/MudGame.class
Binary file not shown.
Binary file added src/NonExistingRoomException.class
Binary file not shown.
Binary file added src/Room.class
Binary file not shown.
Binary file added src/Sfinx.class
Binary file not shown.
Binary file added src/Student.class
Binary file not shown.
Binary file added src/Teacher.class
Binary file not shown.
Binary file added src/World.class
Binary file not shown.
29 changes: 16 additions & 13 deletions src/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,16 @@ public void createWorld(String name) {
placeKeys();
placeBooks();
placeCreatures();
printRooms();
//printRooms();

System.out.println(currentRoom);
}



public void runGame() {
Scanner reader = new Scanner(System.in);
Boolean continueGame = true;

while (continueGame) {
reader = new Scanner(System.in);
System.out.print("What's next?\n> ");
Expand All @@ -79,15 +78,9 @@ public void runGame() {

switch (splitInput[0].toLowerCase()) {
case "help": printHelp(); break;

case "show":
if (twoWords && splitInput[1].toLowerCase().equals("hp"))
System.out.println("Current HP: " + player.getHp());
if (twoWords && splitInput[1].toLowerCase().equals("ongoing"))
player.printOngoing();
if (twoWords && splitInput[1].toLowerCase().equals("completed"))
player.printCompleted();
break;

//EX2
case "show": printShow(twoWords, splitInput[1]); break;

case "drop":
if (twoWords)
Expand Down Expand Up @@ -135,6 +128,15 @@ public void runGame() {
reader.close();
}

private void printShow(Boolean twoWords, String splitInput) {
if (twoWords && splitInput.toLowerCase().equals("hp"))
System.out.println("Current HP: " + player.getHp());
if (twoWords && splitInput.toLowerCase().equals("ongoing"))
player.printOngoing();
if (twoWords && splitInput.toLowerCase().equals("completed"))
player.printCompleted();
}

private void printHelp() {
System.out.println(currentRoom);
String help = "--------------------------------------------\n";
Expand Down Expand Up @@ -351,6 +353,7 @@ private void placeCreatures() {
}
}

//EX3
private void placeBooks() {
int numberOfCourses = courses.size();
int numberOfStudents = students.size();
Expand All @@ -376,7 +379,7 @@ private void placeRandom(Object o) {
}
}


//EX1
// TODO: Ta bort när allt är klart!
public void printRooms() {
for (int i = 0; i < numberOfRooms; i++) {
Expand Down