package mug12; import java.util.Comparator; import java.io.BufferedReader; import java.io.InputStreamReader; import io.rebelsky.Pen; import java.util.Hashtable; public class WorldBuilding implements ThingInterface { // +--------+-------------------------------------------------- // | Fields | // +--------+/ String room; String verb; String addwhat; String removewhat; Hashtable hashrooms; Hashtable hashobjects; // +----------------+------------------------------------------ // | Constructors| // +----------------+ public WorldBuilding(String _name, String _description, String[] _adjacent, String[] _stuffInRoom, String[] _personsInRoom, Hashtable _verbs) //double check that File means what we want it to { this.name = _name; this.description = _description; this.adjacent = _adjacent; this.stuffInRoom = _stuffInRoom; this.personsInRoom = _personsInRoom; this.verbs = _verbs; }//WorldBuilding(String, String, String[], String[], String[], Hashtable) public WorldBuilding(String _name, String _room, String _description, String _attribute) //double check that File means what we want it to { this.name = _name; this.room = _room; this.description = _description; this.attribute = _attribute; }//WorldBuilding(String, String, ) // +----------------+------------------------------------------ // | Public Methods | // +----------------+ public void parseWorld() throws Exception { Pen pen = new Pen(); BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); pen.print("How would you like to change the world? The way to add things to the World is by typing in the following format: add/remove places/things/verbs/people. "); pen.flush(); String input = keyboard.readLine(); String[] array1 = input.split(" "); this.verb = array1[0]; if (this.verb.equals("quit")) pen.println("Goodbye"); else if (this.verb.equals("add")){ if (array1.length >= 2) { this.addwhat = array1[1]; } if (this.addwhat.equals("places")) addPlace(); if (this.addwhat.equals("things")) addThing(); } else if (this.verb.equals("remove")){ if (array1.length >= 2) { this.removewhat = array1[1]; } if (this.removewhat.equals("places")) removePlace(); if (this.removewhat.equals("things")) removeThing(); } } // parseWorld() public void addPlace() throws Exception { Pen pen = new Pen(); BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); pen.print("What do you want to call the room? "); pen.flush(); String roomName = keyboard.readLine(); pen.print("Please give a description of the room. "); pen.flush(); String roomDescrip = keyboard.readLine(); pen.print("What do you want adjacent to the new room? "); pen.flush(); String adjRoom = keyboard.readLine(); String[] arrayOfAdj = adjRoom.split(" "); pen.print("What things would you like to add to the room? "); pen.flush(); String stuffInRoom = keyboard.readLine(); String[] arrayOfStuff = stuffInRoom.split(" "); pen.print("Please list the people in the room "); pen.flush(); String peopleInRoom = keyboard.readLine(); String[] arrayOfPeople = peopleInRoom.split(" "); pen.print("Please list verbs that are valid within the context of the room "); pen.flush(); String validVerbs = keyboard.readLine(); String[] arrayOfVerbs = validVerbs.split(" "); WorldBuidling place = new WorldBuilding(roomName, roomDescrip, arrayOfAdj, arrayOfStuff, arrayOfPeople); // send this object to World's storage } // addPlace() public void addThing() throws Exception { Pen pen = new Pen(); BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); pen.print("What is the thing you would you like to add? "); pen.flush(); String addedThing = keyboard.readLine(); pen.print("In which room would you like to add the thing? "); pen.flush(); String roomOfAddedThing = keyboard.readLine(); pen.print("Please give a description of the thing. "); pen.flush(); String thingDescrip = keyboard.readLine(); pen.print("Please assign an attribute to the thing. "); pen.flush(); String thingAttribute = keyboard.readLine(); WorldBuidling thing = new WorldBuilding(addedThing, roomOfAddedThing, thingDescrip, thingAttribute); // send this object to World's storage } // addThing() public void removePlace(String place) throws Exception { Pen pen = new Pen(); BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); // remove this place from World's storage } // removePlace(String) public void removeThing(String thing) throws Exception { Pen pen = new Pen(); BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); // remove this thing from World's storage } // removeThing() } // class WorldBuilding