CSC152 2004F, Class 31: Weekly Project Discussion (Week 8) Admin: * New project homework. * Don't forget tomorrow's homework: Fix Stacks. Overview: * Action methods * Parameter types * Core methods * Simultaneous users b. Decide whether it makes sense to take strings that name objects as parameters or the objects themselves. (What does the UI have access to?) * Strings: 3 or 4 * Users will be entering most information through the keyboard; rather than forcing the UI group to get objects, they can just send this information "directly" * Perhaps the UI shouldn't have control over individual objects. (We may have to worry about which methods can and cannot be called) * What if two users are interacting with the same object? * Objects: The UI group * Problems with duplicate naming (girl named "Candy" and "Candy") * Reaction: What happens at the UI level? "Throw out candy" * Solution: No duplicate names * Similar problem: How do we distinguish two pizzas? We might have to resort to stupid names like "Pizza1" and "Pizza2" (Is this a UI issue?) * Not sure: many The winner: Strings! a. Decide whether we're better off putting our central action methods within individual classes (e.g., the interactWith(String verb, String person) method) or within the big World class, which will be responsible for keeping track of things (e.g., the interact(String actor, String verb, String target) method). * In individual classes: 0 * Distributes our work. Rather than making world have a big "interact" method, we can implement each "interactWith" method separately. * Other ways to distribute work: At the method level rather than at the class level * In World: Many * Easier to have the interaction happen in the world * Easier to keep track of things: If the interaction changes the person and the object; easier not to have objects mutate themselves. * Key idea of OO-design is that objects are supposed to mutate themselves. * It may affect other things in the world. * The world is responible for keeping track of everything (or so we think), so it needs to be told about actions * Not sure: 3 * Both! if the UI calls 'interact("Bob", "eat", "Pizza1")' the World gets the objects associated with Bob and Pizza1 and call bob.interactWith("eat", pizza1) bob.interactWith would call pizza1.reactTo("eat") c. Completely specify a small core set of methods for the four base classes: World, Place, Person, and Thing. You should think carefully about the parameter types and return types. d. Think about simultaneous users: How do we notify one person that someone else has said something to them? /Note: We will need some way to implement a "game clock" that automatically advances./ Network group HW: * Implement simple client/server. Client types messages, server prints them out. UI group homework: * "Parse" commands from the user. World group: Brad, Leigh, Eryn * Finish interfaces (unless Sam does) * Implement stub classes for all of 'em * How do we build the world in the first place? People group: Kevin, Eric, Gaurav * What characteristics * StubPerson * CrazyPerson: Each time it is asked to do something, picks something randomly from the legal options.