package mug13; import java.util.Vector; import java.util.Random; import java.util.Hashtable; public class PersonObject implements Person { //Field String sex; String major; String name; String description; Hashtable verbs; // hold the integer as per checkVerb Hashtable attributes;//dictionary of attributes Vector inventory;//Vector of strings String currentlocale; String[] greeting = { "Hi! ", "Hello. ", "'Sup. ", "How are you? ", "Greetings. ", "Top of the morning to you. " }; String[] randomcomment = { " ", "Nice weather We're having. ", " ", "Aren't classes tough? ", " ", "I just love Grinnell! ", " ", "RKO rocks! " }; String[] verbandprep = { "go to ", "go hang out at ", "go chill at ", "mosey on over to ", "race to ", "ride our bikes to ", "walk to ", "run to ", "skip to ", "go meet our friends at" }; // should be checked against current location and changed if they match // should use the locations from the world String[] location = { "Harris ", "ARH ", "Noyce ", "Burling ", "Bucksbaum ", "the Forum Grill ", "Carnegie ", "the bookstore ", "the post office ", "Steiner ", "Goodnow ", "Burling 4th ", "Central Campus ", "the PEC ", "my room on East Campus ", "my room on South Campus ", "my room on North Campus ", "the football field ", "the soccer field ", "Mac Field ", "the tennis courts ", "the CDO ", "admissions ", "the Zircle ", "Quad Dining Hall ", "Cowles Dining Hall " }; // this should be class specific String[] activity = { "do homework.", "work on our homework.", "fornicate.", "hook up.", "get it on.", "complain about the opposite sex.", "complain about how much homework we have.", "spread rumors about your roommate.", "abuse illegal substances.", "pop a top.", "have a few beers.", "get wasted.", "plan our futures.", "discuss grad school.", "discuss self governance.", "discuss why harris parties are so cool.", "discuss politics.", "discuss the last atheletic competition.", "save the world." }; //constructor public PersonObject(String _name, String _description, String _sex, String _major, Hashtable _verbs, Hashtable _attributes, Vector _inventory) { this.name = _name; this.description = _description; this.sex = _sex; this.major = _major; this.verbs = _verbs; this.attributes = _attributes; this.inventory = _inventory; } //methods public int react() { return 0; } //react should run and simulate the chance of a reaction by picking a number randomly between //1 and 100, and the AI will act based on the percent that they are given, depending on their character. //observers /** * Get the name of this thing. Every thing is supposed to have a * unique name. */ public String getName() { return this.name; } /** * Get a description of the object, which can then be presented * to the user. */ public String describe() { return this.description; } /** *finds the verbs that can be performed on said object */ public Hashtable verbs() { return this.verbs; } /** *finds the stuff needed to run a verb *returns a -1 if the verb doesn't exist for this object *returns a 0 if the verb does exist but does not change anything *returns a 1 if the verb exists and changes things */ public Integer checkVerb(String verb) { if (this.verbs.get(verb).equals(null)) return new Integer(-1); else { Integer returned = (Integer) this.verbs.get(verb); return returned; } } /** *gets attributes stored as numbers */ public double getNumberAttribute(String name) { Double returned = (Double) this.attributes.get(name); return returned.doubleValue(); } /** *gets atributes stored as words */ public String getWordAttribute(String name) { String returned = (String) this.attributes.get(name); return returned; } public void changeNumberAttribute(String name, Double newValue) { this.attributes.put(name, newValue); } public void changeWordAttribute(String name, String newName) { this.attributes.put(name, newName); } public String[] things() { String[] stuff = new String[this.inventory.size()]; this.inventory.copyInto(stuff); return stuff; } public void addToPack(String name) { this.inventory.add(name); } public void removeFromPack(String name) { this.inventory.remove(name); } // a random chat generator named after its inspiration public String barbiePhone() { Random num = new Random(); return greeting[num.nextInt(greeting.length)] + randomcomment[num.nextInt(randomcomment.length)] + "Let's " + verbandprep[num.nextInt(verbandprep.length)] + location[num.nextInt(location.length)] + "and " + activity[num.nextInt(activity.length)]; } }