Question

Purpose Demonstrate the ability to create and use subclasses and inheritance. This includes overriding method behaviors...

Purpose

Demonstrate the ability to create and use subclasses and inheritance. This includes overriding method behaviors and using polymorphism.

Assignment

Create an Aircraft class that has several properties that are common to all aircraft (Ex: number of engines, seat capacity). You define the name of the Class and the actual fields. The fields MUST BE PRIVATE!!! You must define a constructor that allows you to provide at least some of the field values used for an aircraft. You must define a printCharacteristics() method. Create three subclasses for specialized types of aircraft. An example might be a Fighter, Acrobat, and Freight. You do not have to use these three choices. You define the names of the classes. Each specialized craft should have additional properties that are common to just that type of specialized craft. These fields MUST BE PRIVATE. For each derived class, you must define a constructor that allows you to provide at least some of the field values used for these subclass aircraft. You must define any getter/setter methods you need. Make a SINGLE C++ vector of Aircraft pointers. You will populate this list by reading commands from an input file. This vector will hold pointers to any type of Aircraft including your three derived classes. The commands in the file will cause you to create your Aircraft objects or print them using the printCharacteristics() method. This method must be overridden in each subclass. The output should print a well formatted description of all the specific and inherited information for each craft. (Make sure you up on virtual functions and virtual destructors).

Requirements • Your code must exhibit the use of Polymorphism. Do not create separate arrays for objects of each class. • Your code must exhibit the use of subclasses • Your code must exhibit the use of overridden methods • Your code must exhibit the use of a parameterized STL vector

Deliverables

You must submit your homework through ELearning. You must include UML diagrams of your classes, a Class Hierarchy diagram, your .h and .cpp files, and a commented version of your input file. Notes No late homework is accepted. A nice UML tool is available here: https://www.gliffy.com

Input File Format

The input file is a text file that contains an unknown number of commands. Commands are strings that determine what operations should be performed. If the commands have arguments, they are listed after the command. Multiple arguments will be comma separated. Spaces, tabs, and anything following // can be ignored. This assignment requires you to create 4 separate classes: your aircraft class, your subclass 1, your subclass2, and your subclass 3. In the commands section of the file, these classes will be referred to by number: Class Referred to using Your Aircraft Class 0 Your subclass 1 1 Your subclass 2 2 Your subclass 3 3 The commands all have to do with creating aircraft and printing information about those aircraft. Since you are defining your own classes and subclasses, you will also have to define the arguments that go with the commands. Your commands must provide enough information so that you can execute them.

The commands are: String Command Description n Create a new aircraft. The first arg is the aircraft type. You must define the rest of the arguments needed to create your aircraft of that type: int aircraft type (from the "Referred to using") ... (you define the rest for each aircraft type) Each aircraft should be placed in the aircraft vector. The first aircraft you create will be numbered 1, the second 2, etc... p Print the characteristics of an aircraft in your list. This command takes one argument which represents the actual Aircraft to print. If the argument has the value 0, you print information for all the aircraft. Otherwise, go through the entire list of aircraft and only print the information for the single type of aircraft referred. Remember, the first Aircraft created is numbered 1. Your code must check for proper information for each command. Errors should be handled by printing a message and ignoring the line. Examples of errors include, but are not limited to: unknown commands, commands without the proper number of arguments, commands with arguments that do not make sense, and commands that have the wrong types of arguments.

Example Input File // Commands information: // n - create a new aircraft. If the first arg is 0, then parameters are // int: number of engines // int: seat capacity // // if the first arg is 1, then the parameters are: // int: number of engines // int: seat capacity // String: range and speed description // // if the first arg is 2 then the parameters are: // String: Manufacturer // String: Performance capability description // // if the first arg is 3 then the parameters are: // int: number of engines // String: Freight Company // String: Cargo Capacity n 0, 2, 6 // New Aircraft: 2 engines, seats 6 CS 1337.502,504 F17 Program #4 Page 4 of 4 n 0, 4, 200 // New Aircraft: 4 engines, seats 200 n 1, 1, 1, "Top Speed: Mach 1.2, Max Range: 400 Miles" n 1, 2, 2, "Top Speed: Mach 2, Max Range: 1200 Miles" n 2, "Zivko Edge 540", "Cruise: 333 km/h, Max Roll Rate: 420 degrees/sec, G-limit: 10" n 2, "Pitts Special S-1S", "180HP, certified S-1C for competition aerobatics" n 3, 4, "UPS", "100 UPS Shipping containers" n 3, 4, "FedEx", "14,000 pounds" p 0 p 1 p 2 p 3

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import java.util.LinkedList;
import java.util.ListIterator;

public class Polynomial  {
    // this is a nested static class, it defines a type
   // all the instance varaibles can be access directly inside Polynomial class even though they have
   // private modifier
      private static class Term{
        private double coefficient;
        private int exponent;
          
        public Term(int exp, double coeff )
        {
            coefficient= coeff;
            exponent = exp;
         }
    }
    // instance variables of Polynomial
    // first is the term of the Polynomial with the highest degree
    private LinkedList termList; 
   
   1. public Polynomial() {
      termList = new LinkedList();
     termList.add(new Term(0,0));
    }
  
2. public Polynomial(double a0) {
   termList = new LinkedList();
   termList.add(new Term(0,a0));
}

3. public Polynomial(Polynomial p) {
        
}

4. public void add_to_coef(double amount, int exponent) {
  
}
  
5. public void assign_coef(double coefficient, int exponent) { 
    
}

6. public double coefficient(int exponent)  {
  
}

7. public double eval(double x) {
  
}   The return value is the value of this polynomial with the given value for the variable x.
     Do not use power method from Math, which is very low efficient 
  
  8. public boolean equals (Object obj) {
   if(obj instanceof Polynomial)
   {
     
   }
   return false;
}
    9. public String toString() {
               
    }
  10. public Polynomial add(Polynomial p) {

     }
     
  11. public Polynomial multiply(Polynomial p) {
        
      }
}
Add a comment
Know the answer?
Add Answer to:
Purpose Demonstrate the ability to create and use subclasses and inheritance. This includes overriding method behaviors...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment...

    Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of 100 accounts. Use an array of pointers to objects for this. However, your...

  • The purpose of this is to use inheritance, polymorphism, object comparison, sorting, reading binary files, and...

    The purpose of this is to use inheritance, polymorphism, object comparison, sorting, reading binary files, and writing binary files. In this application you will modify a previous project. The previous project created a hierarchy of classes modeling a company that produces and sells parts. Some of the parts were purchased and resold. These were modeled by the PurchasedPart class. Some of the parts were manufactured and sold. These were modeled by the ManufacturedPart class. In this you will add a...

  • Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and...

    Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...

  • Need help to create general class Classes Data Element - Ticket Create an abstract class called...

    Need help to create general class Classes Data Element - Ticket Create an abstract class called Ticket with: two abstract methods called calculateTicketPrice which returns a double and getld0 which returns an int instance variables (one of them is an object of the enumerated type Format) which are common to all the subclasses of Ticket toString method, getters and setters and at least 2 constructors, one of the constructors must be the default (no-arg) constructor. . Data Element - subclasses...

  • Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program:   Design a class named Person...

    Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program:   Design a class named Person and its two subclasses, Student and Employee. Make Faculty and Staff subclasses of Employee. A Person object has a name, address, phone number, and email address (all Strings). A Student Object has a class status (freshman, sophomore, junior, or senior). Define the status as a final String variable. An Employee Object has an office number, salary (both ints ), and a date hired. Use...

  • Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and...

    Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and name variables (do not include topTrick). Note: The type refers to what the breed typically does; for example, a corgi would be a “cattle herding dog.” A Shiba Inu would be a “hunting dog.” Create the setTopTrick() mutator method Dog is parent class Corgi and Driver are subclasses Complete the Corgi class: Using the UML Class diagram, declare the instance variables. Create the two...

  • Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance...

    Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below MotorVehical.pdf Minimize File Preview User Define Object Assignment: Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results. You are required to create three UML...

  • MEDIA INHERITANCE - C++ You will create an inheritance set of classes. Use proper rules for...

    MEDIA INHERITANCE - C++ You will create an inheritance set of classes. Use proper rules for data types, class definitions, and inheritance (check input/output of data below). You will create a super media class that will define a general form of media. A media properties will consist of the name and price. The media should be able to construct itself out of the arguments sent to it, virtually print both data fields labeled (price to two decimal places) and overload...

  • What is the code for this in Java? Assignment Inheritance Learning Objectives Declare a subclass that...

    What is the code for this in Java? Assignment Inheritance Learning Objectives Declare a subclass that derives from a superclas:s ■ Demon "Declare a variable of the superclass type and assign it an instance of the subclass type strate polymorphic behavior Access the public members of the superclass type Notice how the overridden versions of the subclass type are called Notice how the subclass specific members are inaccessible "Create an array of superclass type and use a foreach loop to...

  • C++ ONLY PLEASE Problem Description: Objective: Create Inheritance Hierarchy to Demonstrate Polymorphic Behavior Create a Rectangle...

    C++ ONLY PLEASE Problem Description: Objective: Create Inheritance Hierarchy to Demonstrate Polymorphic Behavior Create a Rectangle Class Derive a Square Class from the Rectangle Class Derive a Right Triangle Class from the Rectangle Class Create a Circle Class Create a Sphere Class Create a Prism Class Define any other classes necessary to implement a solution Define a Program Driver Class for Demonstration a) Create a Container to hold objects of the types described above b) Create and Add two(2) objects...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT