CIS 247A Week 7 iLab Putting It All Together
Just Click on Below Link To Download This Course:
https://bit.ly/3cVNpLw
CIS 247A Week 7 iLab Putting It All Together
Scenario
and Summary
This week, you will be implementing inheritance by creating a generic Racer
base class along
with two derived classes called StreetTuner and HotRod. You will make the Racer
class abstract
and include the abstract method IsDead() in the Racer class.
iLAB
STEPS
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.
STEP
2: Build the Inheritance Hierarchy
- Create a project called “CIS247_WK7_Lab_LASTNAME”.
- 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
- Provide suitable logic for the ToString method. As always, the
ToString method should reveal
the state of an object. - 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:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
STEP
4: Implement the logic for the
StreetTurner class
- Provide suitable logic for the ToString method. As always, the
ToString method should reveal
the state of an object. - For the IsDead method in StreetTurner, use the logic
below to implement the inherited abstract
base class method called IsDead.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
STEP
5: Construct the Main Program
- Create an array of Racer objects that will hold two Racer objects.
- 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: - Racer name;
- Racer Speed;
- Number of cylinders in the racer’s engine;
- Horsepower of the racer’s engine; and
- 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.]
- 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. - Create a racer object of each type, and invoke the
CollectRacerInformation passing in the
Racer object. Then, store each object in the array. - 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.
Check your output to ensure that you have the desired output and modify your
code as necessary
and rebuild.
STEP
7: Submit Deliverables
Before you post your lab in the dropbox, copy your entire program into a
Notepad file and post
that. I do not need you to zip the project or give me screen shots of the
output.
Submit your lab to the Dropbox located on the silver tab at the top of this
page. For instructions
on how to use the Dropbox, read these Step-by-Step Instructions or watch this
Dropbox Tutorial.


Comments
Post a Comment