Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This week, we will use abstract classes, and transform some of the base class me

ID: 3629852 • Letter: T

Question

This week, we will use abstract classes, and transform some of the base class methods into virtual methods. We will leave out the implementation and make the Airplane class an Abstract class. Then, we will create the same two derived classes: (1) fighter plane and (2) passenger plane, that must implement the virtual methods. Changing the Airplane class to an Abstract means that we can no longer create a generic Airplane object, and that any Airplane object that we do create must be a subclass of the base Airplane class.
Since the architecture of the application is the important learning point of this lab, we will not change the actual algorithms of the methods, but will just move the implementation of the methods into the derived classes.
Deliverables

Step
Deliverable

Lab Steps:

i L A B S T E P S
STEP 1: Create and Set Up Application.

Review the class diagram below and notice the following key points:
The name of the Airplane class has been renamed to Airplane_Abstract and the bold, italic letters specify that the entire class should be defined as an abstract class.
The members in normal case font indicate that these members are declared as class-level members and the implementation of these members is done in the parent class.
Methods in italic letters are pure virtual functions that have no implementation in the base class, and MUST be overridden in the derived classes.
The Move method is a virtual method in the base class, but can be overridden in the derived classes. This will work in the Fighter Jet class in this example, BUT not in the Passenger Airplane class.



STEP 3: Modify the Airplane Class.


Using the Class diagram, modify the Airplane class to:
Specify that the class is abstract
Specify that the Move method is a virtual method
Specify that TurnRight, TurnLeft, Accelerate, and Decelerate are pure virtual methods.
Remove the code from each of the methods (copy and paste it into a Notepad file, since you will want to use it in each of the derived class's implementation of the methods).

STEP 4: Modify the Jet Fighter Class.


Using the Class diagram, modify the Jet Fighter to:
Using the same algorithms and formulas from Week 5 (and Week 3) for the Fighter Jet class, implement each of the pure virtual functions: (1) TurnRight, (2) TurnLeft, (3) Accelerate, and (4) Decelerate.
Override the base class Move method so that the Jet Fighter moves 10 times faster than a generic airplane.

STEP 5: Modify the PassengerAirplane Class.


Using the Class diagram, modify the Passenger Airplane class to:
Using the same algorithms and formulas from Week 5 (and Week 3) for the Fighter Jet class, implement each of the pure virtual functions: (1) TurnRight, (2) TurnLeft, (3) Accelerate, and (4) Decelerate.
STEP 6: Modify the Windows Interface Form.


Ensure that the Windows Form correctly implements each of the operations using the modified class architecture:
List box, or combo box control, that allows the user to select whether the airplane is a generic airplane, a passenger plane, or a fighter plane.
When the user selects the type of plane, create a new object of the identified type.
Add a command button that when selected provides the information about the specific type of airplane object. [Hint: program each event handler to handle a generic airplane object, then use the polymorphic methods].
When the user selects the existing operations, the appropriate object type methods will be invoked.
STEP 7: Compile and Test.

When done, compile your code by clicking on Build, Build application name. Then, debug any errors in the Error Window until your code is error-free.
To execute your code, click Start, and then Start Debugging. Check your output to ensure that you have the desired output. If you need to fix anything, close your execution window and modify your code as necessary and rebuild.

STEP 8: Execute Screen Prints.

Capture the results of each test and paste into a Word Document.

STEP 9: Submit Deliverables.

Step 10
Screen shots of running program results.

Step 11
Zip file with entire Lab files.

Explanation / Answer

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace WindowsFormsApplication1 { public abstract class Airplane_Abstract { private int max_speed = 500; private string name; private string plansPosition; private int numberCreated; public int NumberCreated { get { return numberCreated; } set { numberCreated = value; } } public Airplane_Abstract() { } public override string ToString() { return base.ToString(); } public virtual void Move() { //implementation } public virtual void TurnRight() { } public virtual void TurnLight() { } public virtual void Accelarate() { } public virtual void Decelarate() { } } public class JetFighter : Airplane_Abstract { private string fightertype; public JetFighter() { } public override string ToString() { return base.ToString(); } public override void Move() { //move the implementation of move method here } public override void Accelarate() { //move the implementaion of accelarate method here } public override void Decelarate() { //move the implementatio of decelarate method here } public override void TurnLight() { //move the implementatio of turnlight method } public override void TurnRight() { //move the implementatio of turn right method } } public class PassengerAirplane : Airplane_Abstract { private string name; private int flightno; private int noofpassengers; public PassengerAirplane() { } private void BoardPlane() { //implementation of BoardPlane } public override string ToString() { return base.ToString(); } public override void Move() { //move the implementation of move method here } public override void Accelarate() { //move the implementaion of accelarate method here } public override void Decelarate() { //move the implementatio of decelarate method here } public override void TurnLight() { //move the implementatio of turnlight method } public override void TurnRight() { //move the implementatio of turn right method } } } using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.comboBox1.Items.Add("PassengerAirplane"); this.comboBox1.Items.Add("JetFighter"); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.SelectedItem == "PassengerAirplane") { PassengerAirplane p = new PassengerAirplane(); } else if (comboBox1.SelectedItem == "JetFighter") { JetFighter jf = new JetFighter(); } } } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote