From fdb6a98b1345e84714aa7c710dd4586720fc2d16 Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 24 Mar 2023 13:09:00 -0400 Subject: [PATCH] Modified prototype view class 'GameDisplay' --- Assignment 3/src/ca/cosc3p91/a2/game/GameEngine.java | 5 ++--- .../src/ca/cosc3p91/a2/userinterface/GameDisplay.java | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Assignment 3/src/ca/cosc3p91/a2/game/GameEngine.java b/Assignment 3/src/ca/cosc3p91/a2/game/GameEngine.java index 8758d4c..3dfd320 100644 --- a/Assignment 3/src/ca/cosc3p91/a2/game/GameEngine.java +++ b/Assignment 3/src/ca/cosc3p91/a2/game/GameEngine.java @@ -146,7 +146,6 @@ public class GameEngine implements Runnable { view.printVillageState(this.map,"Current Village State"); view.printGameMenu(); - System.out.println(); Map exploringMap = null; boolean deleteMyHeart = true; while (running) { @@ -158,8 +157,8 @@ public class GameEngine implements Runnable { try { if ((in = view.nextInput()) != null) { String[] args = in.split(" "); - System.out.println("Your Input: "); - System.out.println("\t->" + in + '\n'); + + view.printLastInput(); // reset the map if they aren't exploring if (in.charAt(0) != '4') deleteMyHeart = true; diff --git a/Assignment 3/src/ca/cosc3p91/a2/userinterface/GameDisplay.java b/Assignment 3/src/ca/cosc3p91/a2/userinterface/GameDisplay.java index cb58f3d..691a05f 100644 --- a/Assignment 3/src/ca/cosc3p91/a2/userinterface/GameDisplay.java +++ b/Assignment 3/src/ca/cosc3p91/a2/userinterface/GameDisplay.java @@ -22,10 +22,15 @@ public class GameDisplay { public String nextInput() throws IOException { if (reader.ready()) { - return scanner.nextLine(); + return (input = scanner.nextLine()); } else return null; } + public void printLastInput() { + System.out.println("\nYour Input: "); + System.out.println("\t->" + input + '\n'); + } + public void printVillageState(Map map, String displayName) { Print resourcesPrinter = new Print(displayName, 2);