C#7 Program
STEP 1: Understand the UML Diagram
The UML diagram four classes defined (1) Racer, (2) Engine, (3) Hot Rod, and (4) StreetTuner classes.
The Racer class is the base parent abstract class of the Hot Rod and Street Tuner classes, which is represented by a directed line from the Hot Rod and Street Tuner classes to the Racer class and the end of the line touching the Racer class is a broad, unfilled arrow head. The racer class contains a engine object, which is represented by a directed line from the engine class to the Racer class, with a filled diamond touching the racer class, this line is labeled as a 1 to 1 relationship meaning that each racer object will contain one engine object and each engine is related to a single racer object.
The class's attributes and methods are defined in separate class diagrams, and each class diagram is represented by a rectangular box subdivided into three vertically separated rectangular sub-sections. The top section contains the class name, the middle section contains the class attributes, and the bottom section contains the class methods.
The classes are defined as follows:
Racer abstract Attributes private name string private speed integer private engine EngineMethods public Racer default constructor no parameters public Racer overloaded constructor parameters name string, speed integer, engine Engine public abstract IsDead Boolean public overrides ToStringend class
Engine Attributes private cylinders integer private horsepower integerMethods public Engine default constructor no parameters public overrides ToString returns stringend class
Hot Rod Attributes private blower booleanMethods public HotRod default constructor no parameters public HotRod overloaded constructor parameters name string, speed integer, engine Engine, blower Boolean public overrides IsDead booleanend class
Street Tuner Attributes private nitrous booleanMethods public StreetTuner default constructor no parameters public StreetTuner overloaded constructor parameters name string, speed integer, engine Engine, nitrous Boolean public overrides IsDean boolean public overrides ToString returns stringend class
Press the ESC key to close the image description and return to lecture.
STEP 2: Build the Inheritance Hierarchy
1. Create a project called "CIS247_WK7_Lab_LASTNAME".
2. Build the class structure shown in the UML diagram. Remember to include properties for each class attribute.
STEP 3: Implement the Logic for the HotRod Class
1. Provide suitable logic for the ToString method. As always, the ToString method should reveal the state of an object.
2. For the IsDead() method in HotRod, use the logic to implement the base class abstract IsDead method.
Hint: To generate a random number, use the following code, which returns a random number from 0 to 1:
Random rnd = new Random();
rnd.NextDouble();
STEP 4: Implement the logic for the StreetTurner class
1. Provide suitable logic for the ToString method. As always, the ToString method should reveal the state of an object.
2. For the IsDead method in StreetTurner, use the logic below to implement the inherited abstract base class method called IsDead.
STEP5: Construct the Main Program
1. Create an array of Racer objects that will hold two Racer objects.
2. Write a method called CollectRacerInformation that accepts as an argument a Racer object, and then prompts the user to provide the following information for each racer:
a. Racer name;
b. Racer Speed;
c. Number of cylinders in the racer's engine;
d. Horsepower of the racer's engine; and
e. Nitrus or blower option, depending on the type of Racer object.
[Hint: In order to be able to collect all information for the derived classes as well, consider creating a base class method called ReadRacerData in the Racer class, which you will then override in the derived classes to capture the required info per class. Call the ReadRacerData method within the CollectRacerInformation method.]
3. Write a method called "DisplayRacerInformation" that accepts as an argument a Racer object, and then displays all of the information for the specific racer type.
4. Create a racer object of each type, and invoke the CollectRacerInformation passing in the Racer object. Then, store each object in the array.
5. Iterate through the Racer array list and, for each Racer, display all of the Racer's attribute information (call the DisplayRacerInformation method for each object). Don’t forget to indicate whether or not the Racer is dead!
STEP 6: Compile and Test
When done, compile and run your program.
Then, debug any errors until your code is error-free.
STEP 7: Submit Deliverables
· Capture the console output window and paste into a Word document.
· Put the zip file and screen shots (Word document)