CSC241: Homework 5
In this homework we expand the set of commands to the full possible set. Add the functionality for the following commands:
- CreatureName:clean - this command forces the creature with name CreatureName to clean the room. This command has multiple special cases, so be careful to implement all of them. The respect of the PC is altered accordingly, other Creatures react accordingly (possibly altering the PC's respect even further), etc. If a Creature with name CreatureName cannot be found in the current Room, output a sensible message and repeat the command loop.
- CreatureName:dirty - same as above, only force the creature to dirty the current room rather than clean it.
- CreatureName:north - force CreatureName to go north. If it cannot (there is no room to the north or it is full), output a sensible message and repeat the command loop. Remember that when it enters the new room, it may not like its state, triggering a chain of reactions as per the project description.
- CreatureName:south, CreatureName:west, CreatureName:east - same as above for the respective direction.
In order to optimize the finding of a Creature with a certain name in a Room, keep the array with Creature references that every Room has sorted at all times based on the Creature names. To do that, implement and execute quicksort on the array every time a Creature enters or leaves the Room. Then, when you are looking for a Creature with a certain name in a Room, implement and execute binary search on the array of Creature references.
Note that this homework should complete the functionality of the project. Do read the complete project description to see whether you have missed anything. Did you implement a help message? Did you do the "lickface", "growl", and the like messages? Did you check whether the PC's respect is 0 or 80 to see if the game should end in shame or praise? etc.