CS19 Fall 2014
Assignment 5 (Splat the Schmoo)
This is a new Schmoo game. Schmoos are imaginary creatures who love being splatted with juicy mud balls. You, being a Schmoo lover, try to make Schmoos happy by tossing mud balls at them.1
Create a class named Schmoo. Your Schmoo class needs to have two doubles (x and y) which represent the location of the Schmoo (in feet.) Note that x and y can be positive or negative. Your Schmoo class also needs an int (mud), initally 0, that tells you how many times that Schmoo has been hit with mud. (A mud ball will hit a Schmoo if it lands within 5 feet of the Schmoo.) Your Schmoo should have an output function that displays the coordinates of the Schmoo as well as the number of times that the Schmoo has been hit with mud (see the provided sample for the required format.) Since Schmoos only like people who throw mud at them, your Schmoo class should not use the friend class feature. Your Schmoo class should have a Copy Constructor.
Create a Linked List class named SchmooList, and a link node class named Linknode. (This will be a customized Linked List (special features described below) based on the 3-class Linked List as described in class.)
Your program will read its input from STDIN and write its output to STDOUT. A sample input file and resulting output will be provided. After you have completed reading the input, Your program should print a two line header (name, pengo, email, etc.), then print the number of Schmoos in the list and then call the list printAll() function. The input file will consist of a list of commands, one per line. There are three different commands, and each will consist of two words followed by two doubles. The commands are "add schmoo", "throw mud", "remove schmoo". You must check for the commands in a case-insensitive manner. The three commands should call your insertFront(), ThrowMudAt(), and RemoveAt() functions respectively.
The SchmooList class must support at a minimum, the following functions:
- A constructor that initializes the list to empty
- A destructor that correctly deallocates all the objects in the list
- A public function called insertFront that the user calls to insert (by reference) a Schmoo into the first position in the list.
- A public function named throwMudAt(double, double) that "throws mud at the given x,y coordinates". This function should add one to the mud value of any Schmoo in the list that is within 5.0 feet of the given coordinates. (Within 5.0 means that the distance is less than or equal to 5.0)
- A public function named removeAt(double, double) that removes any Scmoo that is within a distance of 1.0 feet of the given coordinate. Note that it is possible that every Schmoo in the list could be removed with this command.
- getPopulation() returns the number of Schmoos in the list
- printAll() send each Schmoo to STDOUT (one per line.) in list order, starting with the first.
- Add other member functions as you deem appropriate.
1. From The Best of Creative Computing Magazine, Volume One, Edited by David H. Ahl, Creative Computing Press, 1976