This program should be called Gobots.java. To hand in, email to Lifeng Zhang, zlfpeak@iastate.edu.
It is the future. Many groundskeepers, programmers, etc., have been replaced by robots. "Naturally," the former humans who did these jobs have lifetime retirement options (the not so nice other possibility – they’re on the streets). However, robots cannot be trusted to manage other robots, so it is illegal to have a robot write software for controlling other robots. That is why you were hired: programming is one of the few remaining professions open to humans, so you are important and well-paid, but don't have that lifetime retirement option available to people who have been replaced by robots. Your job is to write an object oriented system in Java for controlling the activities of ISU’s robots.
Define a base robot class that contains the member variables model and serialNumber, which are declared private. Since all robots have a model number and a serial number, it makes sense to put these in the base robot class. Every robot, when created with its constructor, should be given a unique serial number automatically. (You can do this with a static variable which is defined to have an initial value of say 0. Then when the constructor runs, the serial number is set to the value of the static variable and the static variable is then incremented. That way, every newly constructed robot has its own serial number set to the static (i.e. shared) variable which serves to remember the state of the serial number from one robot constructor call to the next.)
Some robots can move around, for example mowing and vacuuming robots. Define a derived class for mobile robots. This class should contain a 2-D array for storing doubles. (Each double codes for the properties of a particular square meter of the campus in a large 2-D array of square meters, but you need only initialize the array to all 1.0’s.)
Some robots sit at desk jobs (secretary robots, as well as highly unauthorized robots at Microsoft's hidden offshore site where these super-secret robots write programs for other robots to execute, as part of "the plan"). Desk job robots need opposable thumbs. Define a derived class for desk robots, and give them member variables for storing their number of fingers and thumbs (default value: 12 fingers and 3 thumbs, since they have what many people wish they had, namely three hands).
Then there are manager robots. For example, the president of the university would be such a robot, although its secretary would have to be human to ensure that the president robot properly manages the other robots since, as mentioned earlier, robots can’t be trusted to manage other robots. Manager robots are like desk robots (so they should inherit from your desk robot class), except that they also need built-in printers. Give them a variable for number of sheets left in the hopper, and a method that sends strings to the printer (for this assignment, just print to the screen, don't actually try to have your program make hard copies). This method takes as an argument the string to be printed.
Write an interface called Info. Info contains prototypes for two methods: programmer(), and serialNumber(). The base robot class in your program should implement this interface as follows. The programmer() call should print the name of the class and the name of the programmer (i.e. you), and serialNumber should print the serial number of the robot.
Your main method is in a class by itself, called Gobots. The main method should have a loop that prints out each day of the week (for 4 weeks, say). On Tuesdays it causes the president robot to print a hello message to the campus. On Wednesdays the president robot issues a proclamation addressed to parents of students praising the quality of the educational experience at ISU. On Fridays the president robot prints a message asking faculty to raise more money.
On Tuesdays the main() method has a mower robot shovel snow from the campus grounds (this actually takes until the following Tuesday, but you can assume that once the mower robot's goShovel() method is started, it runs all week on its own). For our purposes, goShovel() need only print out the message “now shoveling the campus grounds.” This mower also happens to mow the grass during the summer but you don't need to worry about that. Likewise, if it is winter but there is no snow, it cleans all the you-know-what off the sidewalks.
The main method should declare an array of desk robots. On Thursdays, it commands each desk robot (by looping through the array) to test its thumbs by calling its thumbTest() method, which prints a dot ('.') if the thumbs are ok (you can assume they are or are not as you like for this assignment). This is due to evidence that Firebots, Inc. has been covering up a tread separation problem on its robots’ thumbs which can lead to serious paper rollovers.
Before terminating, main( ) prints out the serial numbers of the president and mower robots, and one of the desk robots, by calling serialNumber(). It then prints out a list of the robot classes and who the programmer was for each class, by calling programmer() for each class.
NOTE: if you took CPRE 485, then your program should include a GUI. The GUI should allow people to click to view the state of various variables in the program.