package mug13; import java.util.Vector; import java.util.Hashtable; /* * Creates a world testWorld and puts Sam, in the MathLAN, with the Pizza. * (except that this creator doesn't actually put the pizza into the mathlan, * sam can perform no actions on the pizza) * */ public class TestCreator { public static void main(String[] args) throws NotHereException, InvalidTargetException, NameTakenException { sample(); } // main(String[]) public static World sample() throws NotHereException, InvalidTargetException, NameTakenException { // Create the world. WorldBuilder testBuilder = new WorldBuilderObject(); RealWorld testWorld = new RealWorld(testBuilder); // Create the one room in the world. Place mathLAN = new PlaceObject("The MathLAN", "THE place to be.", new Vector(), //adjacents new Vector(), //stuff in room new Vector(), //people in room new Hashtable()); //verbs testBuilder.addLocation(mathLAN); // Create an object. Hashtable pizzaVerbs = new Hashtable(); pizzaVerbs.put("eat", new Integer(1)); Hashtable pizzaAttributes = new Hashtable(); pizzaAttributes.put("parts", new Integer(4)); Thing pizza = new ThingObject("pizza", "yummy, cheesy, Chicagoy goodness", pizzaVerbs, pizzaAttributes); // Add our new thing to the world. testBuilder.addThing(pizza); pizza.changeWordAttribute("location", "The MathLAN"); mathLAN.addThing(pizza.getName()); // Create a new person Hashtable samVerbs = new Hashtable(); Verb eat = new Eat(testBuilder); samVerbs.put("eat", eat); Verb say = new Say(testBuilder); samVerbs.put("say", say); Person sam = new PersonObject("Samuel A. Rebelsky", "The really nasty professor.", "male", "computer science", samVerbs, new Hashtable(), //attributes new Vector()); //stuff sam.changeWordAttribute("location", "The MathLAN"); testBuilder.addPerson(sam); mathLAN.addPerson(sam.getName()); // Create another new person Person angeline = new PersonObject("angeline", "The only player.", "female", "computer science", samVerbs, new Hashtable(), new Vector()); angeline.changeWordAttribute("location", "The MathLAN"); testBuilder.addPerson(angeline); mathLAN.addPerson(angeline.getName()); return testWorld; } //sample() }//TestCreator.java