CIS247C Lab 6 New – Abstract class and UML Diagram with screenshots – Perfect Solution – Instant Delivery

Lab Price = $12
Please feel free to send us your queries at: support@iqrajavaid.com
Payment methods

Add to Cart

Buy Now

View Cart


Problem Statement

Lab Overview
Week 6
Scenario/Summary
The purpose of this lab is to practice using an abstract parent class. Let’s have some fun creating Pirate classes!
Deliverables
The deliverable for this lab is
• UML Class Diagram; and
• a Word document that contains the project code and screenshots.
Required Software
Microsoft Office: Word
Use a personal copy, or access the software at https://lab.devry.edu (Links to an external site.)Links to an external site..
Final Step (submitting your lab)
Visio 2013 or newer
Use a personal copy, or access the software at https://lab.devry.edu (Links to an external site.)Links to an external site.. You can get a personal copy through the Student Software Store.
Steps: 1
Visual Studio 2015
Use a personal copy, or access the software at https://lab.devry.edu (Links to an external site.)Links to an external site.. You can get a personal copy through the Student Software Store.
Steps: 2–4

Lab Steps
Step 1
Let’s have some fun! In this lab, we are going to create an abstract Pirate class. Then, we are going to create CaptainPirate and ZombiePirate child classes!
Create the UML class diagram to show the inheritance relationship between the Parent class and the Child classes.
• Open Visio and create a new diagram using the UML Class template.
• Save the diagram as Week 6—Abstract Parent Class With Pirates.
• Drag a class shape to your work area.
o Change the class name to Pirate.
o Add the following attribute and make it protected so that the Child classes have direct access to them.
 name as a string (remember to make it protected by using a hashtag/pound symbol)
o Add the following methods, and make them virtual so that the Child classes can override them.
 speak() that returns a string
 toString() that returns a string
 We have a problem, though! How does a Pirate object speak? We have to know what kind of Pirate object it is so that we can tell it how to speak. In other words, a CaptainPirate is going to speak much differently than a ZombiePirate. Because we do not know how a general Pirate object speaks, we have to make the method abstract. In Visio, we make the method abstract by italicizing it (make the whole line italics).
• It is time to do some inheritance! Drag another class shape to your work area, and place it below the Pirate class.
o Change the name of the new class to CaptainPirate.
o Add the following attribute, and make it private because we do not expect to create Child classes off of the CaptainPirate class. Notice that we do not need to add the name attribute because we inherit it from the Parent class!
 pet as a string
o Add the following methods to override the parent’s methods and to allow the child objects to behave differently than the parent objects.
 speak() that returns a string
 toString() that returns a string
• Let’s do some more inheritance! Drag another class shape to your work area and place it below the Pirate class and to the right of the CaptainPirate class.
o Change the name of the new class to ZombiePirate.
o Add the following attribute and make it private because we do not expect to create Child classes off of the ZombiePirate class. Remember that we automatically get the name attribute because we inherit it from the Parent class.
 brainHunger as a short
o Add the following methods to override the parent’s methods and to allow the child objects to behave differently than the parent objects.
 speak() that returns a string
 toString() that returns a string
• We have our three classes on our Visio diagram. We need to make them related!
o Drag an inheritance arrow off the template and drop it on your diagram.
o Drag the tail of the arrow to the Child class (CaptainPirate) and the head of the arrow to the Parent class (Pirate). This inheritance arrow states that the CaptainPirate inherits from the Pirate class.
o Drag an inheritance arrow from the template, and connect the ZombiePirate class to the Pirate class. Remember that the arrowhead should point to the Parent class, which is the Pirate class.
• Save your file!
Step 2
Create a C++ project, and call it Week 6—Abstract Parent Class. Now, let’s realize the UML class diagram (take the UML class diagram to code).
• Create a Pirate class using a separate header file and implementation file.
o Review your UML class diagram for the attributes and behaviors.
 The speak() method should be abstract because we do not know how a Pirate speaks until we know what kind of Pirate the object is. To make the method abstract, set the virtual method to 0 like this.

virtual string speak() = 0; // pure virtual method — abstract method
• Create a CaptainPirate class using a separate header file and implementation file.
o The CaptainPirate class needs to inherit from the Pirate class
o The speak() method should return a statement that you would expect from a CaptainPirate like this.

return “Yaaarrr! It be a ” + pet + “! \nYaarrr Scallywags! Swab that poop deck!”;
o The toString() method should return the Pirate toString() method plus a little more. For example: return Pirate::toString() + “, pet: ” + pet;
o Create a ZombiePirate class using a separate header and implementation file.
 The ZombiePirate class needs to inherit from the Pirate class.
 The speak() method should return a statement based on how hungry the ZombiePirate has become (reference the brainHunger). For example:
string ZombiePirate::speak(void)
{
// say something based on the hunger level
switch (brainHunger)
{
case 0:
return “Yum. I just ate a brain!”;
break;
case 1:
return “I’m getting a little hungry… Are there any brains out there?”;
break;
case 2:
case 3:
return “I’m getting very hungry!! I need a brain to eat!!”;
break;
case 4:
case 5:
return “BRAINS!!!! GIVE ME BRAINS NOW!!! I NEED TO EAT BRAINS NOW!!!”;
break;
default:
return “Error. Something went wrong.”;
break;
}
}
Step 3
Let’s test our classes and use polymorphism. Add a Source.cpp to your project.
o Create a main method for your application.
o In the main method, check for memory leaks using this code.
// check for memory leaks
#if defined(DEBUG) | defined(_DEBUG)
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
• Create an array of Pirate pointers like this.

Pirate* pirates[3];
• At each pointer reference, create a new child object (CaptainPirates and ZombiePirates). For example: pirates[0] = new CaptainPirate( “Jack”, “Parrot” );
• Create a for loop, and make the three pirate objects speak. Notice that the CaptainPirate objects return a different statement than the ZombiePirate objects even though they are all located in the Pirate array! How does this happen? Polymorphism! The Parent morphs (changes into) the many different Children and behaves like the Children! Remember that poly means many and morph means change into.
• Now, create a method that displays the Pirate object’s information. Plus, the method should determine which child is being held and then show the specific child information. You can determine the child information by using a dynamic_cast.

CaptainPirate* cp = dynamic_cast( ptrPirate ); // NULL if it does not work
if( cp != NULL )
{
cout << "Pet: " << cp->getPet( ) << endl;
}
• Finally, we need to clean up our memory because we used the new keyword. Remember that the new keyword creates the object on the memory heap, and we are responsible for cleaning up the memory heap. Use a for loop to delete the three Pirate objects that we created.
Step 4
Create a Microsoft Word document called Week 6 Lab. At the top, put your information, including your name, course, Week 6 Lab, and the date.
Run your application. Take screenshots while your application is running to demonstrate that it works properly. Remember to hold down the Alt key and the PrtScrn key at the same time (Alt + PrtScrn) to take screenshots of the active window only. Paste these screenshots into your Word document.
Put the file name for each file in the Word document below the screenshots. Bold the file name, and increase the font. Copy and paste the code for each file below its file name. You should have nine files for your project.
Submit the Word document.

Relevant Material
Screenshots
Lab 6: UMLDiagram

Lab 6: UMLDiagram

Lab 6: output

Lab 6: output

Lab 6: NoMemoryLeaks

Lab 6: NoMemoryLeaks

Instructions
* If you want to purchase multiple products then click on “Buy Now” button which will give you ADD TO CART option.Please note that the payment is done through PayPal.
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at support@iqrajavaid.com.
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at support@iqrajavaid.com and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at support@iqrajavaid.com.
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************
Privacy Policy
We take your privacy seriously and will take all measures to protect your personal information.
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
Refund Policy
Incase you face any issues with the tutorial, please free to contact us on support@iqrajavaid.com
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.
Payment Details
Lab Price = $12
Please feel free to send us your queries at: support@iqrajavaid.com

Payment methods

Add to Cart

Buy Now

View Cart