Placeholder

CIS247A Week 7 iLab Putting It All Together

$19.00

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.

Description

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:
Random rnd = new Random(); rnd.NextDouble(); Pseudocode for the IsDead method of HotRod Random rnd = new Random(); boolean dead if (speed > 50 && rnd.NextDouble() > 0.6) if (engineHorsePower < 300 && blower=true) dead = false else dead = true end if else if (speed > 100 && rnd.NextDouble() > 0.4) if (engineHorsePower >= 300 && blower = true) dead = true else dead = false end if else dead = false end if
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.
Pseudocode for the IsDead method of StreetTuner Random rnd = new Random(); boolean dead if (speed > 50 && rnd.NextDouble() > 0.6) if (engineHorsePower < 300 && nitrous=true) dead = false else dead = true end if else if (speed > 100 && rnd.NextDouble() > 0.4) if (engineHorsePower >= 300 && nitrous = true) dead = true else dead = false end if else dead = false end if
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.
SCREENSHOTS
SOLUTION
PAYMENT
The solution includes a Visual Studio (c#) project
Attachments [Move over files to preview content of those files]
CIS247A_Week_7_iLab.zip (125.38 KB)
CIS247A-Week-7-Screenshot.png
Visual Studio project
CIS247A_WK7_Lab
CIS247A_WK7_Lab
App.config
bin
Debug
CIS247A_WK7_Lab.exe
CIS247A_WK7_Lab.exe.config
CIS247A_WK7_Lab.pdb
CIS247A_WK7_Lab.vshost.exe
CIS247A_WK7_Lab.vshost.exe.config
CIS247A_WK7_Lab.vshost.exe.manifest
Release
CIS247A_WK7_Lab.csproj
LogicTier
Engine.cs
HotRod.cs
Racer.cs
StreetTuner.cs
obj
Debug
CIS247A_WK7_Lab.csproj.FileListAbsolute.txt
CIS247A_WK7_Lab.csprojResolveAssemblyReference.cache
CIS247A_WK7_Lab.exe
CIS247A_WK7_Lab.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Presentation Tier
ApplicationUtilities.cs
InputUtilities.cs
Program.cs
Properties
AssemblyInfo.cs
CIS247A_WK7_Lab.sln
CIS247A_WK7_Lab.v12.suo
Preview Engine.cs
xxxxxx xxx xxxxxxxxx;
xxxxxx xxxxxx xxxxxxxxxx;
xxxxxx xxxxxx()
{
cylinders = 0; horsePower = 0; }
public double HorsePower { get { return horsePower; } set {
xx (xxxxx >= 0)
xxxxxxxxxx = xxxxx;
xxxx
xxxxxxxxxx = 0;
}
}
Preview HotRod.cs
xxxxxx xxxxxx()
: xxxx()
{
xxxxxxxx = xxxxx;
}
public override bool IsDead() { Random rnd = new Random(); bool dead;
if (speed > 50 && rnd.NextDouble() > 0.6){ if (engine.HorsePower < 300 && isBlower) dead = false; else dead = true; } else if (speed > 100 && rnd.NextDouble() > 0.4){
xx (xxxxxx.xxxxxxxxxx >= 300 && xxxxxxxx)
xxxx = xxxx;
xxxx
xxxx = xxxxx;
}
xxxx
Preview Racer.cs
xxxxxxxxx xxxxxx xxxxx;
xxxxxx xxxxxx xxxxxx;
xxxxxx xxxxxxxx xxxx xxxxxx();
xxxxxx xxxxx()
{ name = “”; speed = 0; engine = new Engine(); } public string Name { get { return name; } set
{
xx (xxxxx !=xxxx)
xxxx = xxxxx;
xxxx
xxxx = “”;
}
Preview StreetTuner.cs
xxxxxx xxxxxxxxxxx()
: xxxx()
{
xxxxxxxx = xxxxx;
}
public override bool IsDead() { Random rnd = new Random(); bool dead;
if (speed > 50 && rnd.NextDouble() > 0.6) { if (engine.horsePower < 300 && isNitrus) dead = false; else dead = true; } xxxx xx (xxxxx > 100 && xxx.xxxxxxxxxx() > 0.4)
{
xx (xxxxxx.xxxxxxxxxx >= 300 && xxxxxxxx)
xxxx = xxxx;
xxxx
xxxx = xxxxx;
Preview ApplicationUtilities.cs
xxxxx xxxxxx;
xxxxx xxxxxx.xxxxxxxxxxx.xxxxxxx;
xxxxx xxxxxx.xxxx;
xxxxx xxxxxx.xxxx;
namespace CIS247A_WK7_Lab { public class ApplicationUtilities { public static void DisplayApplicationInformation() { Console.WriteLine(“Welcome the Basic Employee Program”);
xxxxxxx.xxxxxxxxx(“xxx247x, xxxx 7 xxx”);
xxxxxxx.xxxxxxxxx(“xxxx: xxxx xxxx”);
xxxxxxx.xxxxxxxxx(“xxxx xxxxxxx xxxxxxx xxxx xxxxx xx x xxxxxx, xxxx xxxxx xxx xxxxxxxxxxxx xxxx xxxxxxxxxx xxx xxxxxxx xxx xxxxx xx xxxxxxxx xxxxxxx xxxxx xxxxxxxxx xxx xxxxxxxx.”);
xxxxxxx.xxxxxxxxx();
}
xxxxxx xxxxxx xxxx xxxxxxxxxxxxxx(xxxxxx xxxxxxxxxxx)
Preview InputUtilities.cs
{
xxxxxx xxxxxxxx = xxxxxx.xxxxx;
xxxxxxx.xxxxx(“xxxxx xxx ” + xxxxxxxxx + “: “);
xxxxxxxx = xxxxxxx.xxxxxxxx();
return strInput; } public static string getStringInputValue(string inputType) { string value = String.Empty; bool valid = false; string inputString = String.Empty; do { inputString = GetInput(inputType); if (!String.IsNullOrEmpty(inputString)) {
xxxxx = xxxxxxxxxxx;
xxxxx = xxxx;
}
xxxx
{
xxxxx = “xxxxxxx xxxxx”;
Preview Program.cs
xxxxxx xxxx xxxxxxxxxxxxxxxxxxxxxxx(xxxxx xxxxx)
{
xxxxx.xxxx = xxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxx(“xxxxx xxxx”);
xxxxx.xxxxx = xxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxx(“xxxxx xxxxx”);
xxxxx.xxxxxx.xxxxxxxxx = xxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxx(“xxxxxx xx xxxxxxxxx”);
racer.engine.HorsePower = InputUtilities.getDoubleInputValue(“Horsepower”); if (racer is HotRod) { string option = InputUtilities.getStringInputValue(“Has Blower (yes or no)”); if (option.ToUpper().Equals(“YES”)) { ((HotRod)racer).IsBlower = true; } else { ((HotRod)racer).IsBlower = false; }
}
xxxx
{
xxxxxx xxxxxx = xxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxx(“xxx xxxxxx (xxx xx xx)”);
xx (xxxxxx.xxxxxxx().xxxxxx(“xxx”))
{
Price: $19
$25
Save $6 (24%)
Buy Now
Checkout
Added to cart
Add to Cart
Checkout
Added to cart
Note: We offer a discount for buyers who purchase multiple items.
You May Also Like:
CIS247A Week 1 iLab Creating a User Interface
CIS247A Week 2 iLab Object Construction and Data Abstraction
CIS247A Week 3 iLab Overloaded Methods and Static Methods Variables
CIS247A Week 4 iLab Composition and Class Interfaces
CIS247A Week 5 iLab Composition Inheritance and Polymorphism
CIS247A Week 6 iLab Abstract Classes

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.