package mug12; import java.io.BufferedReader; import java.io.InputStreamReader; import rebelsky.io.Pen; import java.util.Comparator; /** * A really simple World for testing the MUG. * * @author Angeline Namai * @author Kyle Gonnerman * @author Michael Claveria * @version 1.0 of November 2004 */ public class StubWorld implements WorldInterface { /** * The broadcaster that we call when we want to broadcast a message. */ Broadcaster b; // +----------------+------------------------------------------ // | Public Methods | // +----------------+ /** * Find all the people in a room */ public String[] listPeople(String room) { return new String[] { "angeline", "eryn", "samr" }; } // listPeople(String) /** * Record that an interaction has happened. Return a comment on the * results of the action. * * @exception * If the action is invalid or the object is invalid or ... */ public String perform(Action tim) throws InvalidVerbException, InvalidTargetException { double d = Math.random(); double e = Math.random(); if (e < 0.2) { b.broadcast("Alice eats the mushroom.", null); b.broadcast("Alice says 'Ooh! I seem to be getting smaller'.", null); b.broadcast("Grace Slick starts to sing a song.", null); } if (d < 0.5) return "Done."; else if (d < 0.75) throw new InvalidVerbException(); else throw new InvalidTargetException(); } // perform(Action) // World needs to implement getLocation, listContents, printStuffInRoom, describeThing. // Our implementations are just stubs for testing. public String getLocation(String username) { return "Haines"; } // getLocation(String) public String[] listContents(String room) { return new String[] {"computers", "beer", "beds", "pizza"}; } // listContents(String) public String describe(String thing) { return "Damn ugly!"; } public void specifyBroadcaster(Broadcaster _b) { this.b = _b; } // specifyBroadcaster(Broadcaster) } // class ReadAndParse