Robot Refactoring
Objects & Responsibilities, First Pass
What should a main
method do?
- Construct starter objects
- Push the first "domino" -- get things started
What objects do we need?
- a Talking Robot
- (and a
main
method, which is not an object)
What responsibilities do these objects have?
Talking Robot:
- get the time
- say a phrase (partly random, partly based on time)
- respond to a question/phrase that comes from the user
- ==> The robot seems to need a
clock
main:
- construct the robot
- run some tests:
- get the time
- ask the robot to say a phrase numerous times
at different clock times
- ask the robot to respond to several different
questions from the user
- ==> main needs a way to get the
user questions
- ==> main may need access to the clock
to force different test cases
Alyce Brady, Kalamazoo College