Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Classes! Various flying objects can be described as follows: An Airplane class, which has the following attributes: a brand (String type), price (double type)

The Classes! Various flying objects can be described as follows: An Airplane class, which has the following attributes: a brand (String type), price (double type) and horsepower (int type). A Helicopter is an Airplane that additionally has the following: a number of cylinders (int type), a creation year (int type), and a passenger capacity (int type). A Quadcopter, is a Helicopter that additionally has the following: max flying speed (int type), which indicates its maximum moving speed A Multirotor is a Helicopter that additionally has the following: number of rotors (int type), which indicates its number of rotors/blades that it has. A UAV (Unmanned aerial vehicle/Drone) class has the following attributes: weight (double type), and price (double type). An AgriculturalDrone (which is used for crop production) is UAV that additionally has the following: brand (Sting type), and carry capacity (int type). A MAV (Micro Air Vehicle), is a miniature UAV that has a size restriction (and can be as small as few centimeters. It has the following: model (String type) and size (double type). Part I: 1. Draw a UML representation for the hierarchy of the above-mentioned classes. Your representation must also be accurate in terms of UML representation of the different entities and the relation between them. You must use software to draw your UML diagrams (no hand-writing/drawing is allowed). In case additional classes are needed to reflect how the above classes are related in real-life, you can add these classes. . 2. Write the implementation of the above-mentioned classes using inheritance and according to the specifications and requirements given below: You must have 5 different Java packages for the classes. The first package will include the Airplane class. The second package will include the Helicopter, and the Quadcopter classes. The third package will include the Multirotor class. The fourth package will include UAV class, and the last package will include the AgriculturalDrone and MAV classes, For each of the classes, you must have at least three constructors, a default constructor, and a copy constructor. The default constructor should initialize the object with any values that make sense though). The parameterized constructor will accept enough parameters to initialize ALL the attributes of the created object from this class. For instance, the parameterized constructor of the Quadcopter class must accept 7 parameters to initialize the brand, the price, the horse power, the number of cylinders, the creation year, the passenger capacity, and the maximum Mlying speed. The copy constructor creates a new object that is an exact copy of the passed objet. An object creation using the default constructor must trigger the default constructor of its ancestor classes, while creation using parameterized constructors must trigger the parameterized constructors of the ancestors. The copy constructor creates a new object that is an exact copy of the passed objct. An object creation using the default constructor must trigger the default constructor of its ancestor classes, while creation using parameterized constructors must trigger the parameterized constructors of the ancestors. For each of the classes, you must include at least the following methods: accessors, mutators, toStringO and equals() methods (notice that you are always overriding the last two methods). Page 2 of 5 Comp249/Winter 2022 - Assignment 2 I tributes ante The toString0 method must return clear description and information of the object, including its exact type (ie \"This Agricultural Drone is manufactured by Agridrones. It weighs 340 pounds, and costs 98000s. It can carry up to 25 Kg....). The equals() method must first verify if the passed object (to compare to) is null and if it is of a different type than the calling object. The method would clearly return false if any of these conditions is true; otherwise the comparison of the attributes is conducted to see if the two objects are actually equal. Two objects are equal if the values of all their attributes are equal. For all classes you must use the appropriate access rights, which allow most case of use/access without compromising security. Do not use most restrictive rights unless they make sense! When accessing attributes from a base class, you must take full advantage of the permitted rights. For instance, if you can directly access an attribute by name from a base class, then you must do so instead of calling a public method from that base class to access the attribute. 3. Write a driver program that contains the main() method), which will utilize all of your classes. The driver class can be in a separate package or in any of the already existing packages. Besides the main() method, the driver will also include another static method called findLeast AndMostExpensive UAVO. The description this is as follows: The findLeastAnd Most Expensive UAVO should be able to accept any array of flying objects as a U. . . For all classes you must use the appropriate access. without compromising security. Do not use most restrictive rights unless they make sense! When accessing attributes from a base class, you must take full advantage of the permitted rights For instance, if you can directly access an attribute by name from a base class, then you must do so instead of calling a public method from that base class to access the attribute 3. Write a driver program that contains the main() method), which will utilize all of your classes. The driver class can be in a separate package or in any of the already existing packages. Besides the main method, the driver will also include another static method called find Least And MastExpensive UAVO. The description this is as follows: The findLeast And MostExpensive UAVO should be able to accept any array of flying objects as a parameter. The method however must find both the least expensive and the most-expensive UAV objects in that array (if any exists). If so, the method must find then display (using toString), the information of these two UAV objects. If only one UAV object exists in the passed array, then it is considered as the least and the most expensive. If no UAV objects are found, the method must display something to that effect A: Q . G A A 4. In the main() method you must: Create at least 15 objects from the classes, and display their information (you must take advantage of the toString() method) Test the quality of some of the created objects using the equals() method. You should test at least the equality of two objects from different classes, two objects from the same class with different values and two objects with similar values. In other words, you should include enough test cases to test your implementation Create 2 arrays, each of 15 to 20 of these flying objects and fill these mays with various objects from these classes. The first array must include at least one object from each of the classes; while the second array should not have any UAV objects. (HINT. Again, do you need to add something else to the classes described above? If so, go ahead with that!) Finally call the ind Least And MostExpensive UAVO once with the first array as a parameter and once with the second array. This should display what is needed! 5. Does my program work correctly, or does it misbehave! WHY? Investigate the output of your program! You will need to submit a separate document (pdf MS-Word, or text) along with your assignment indicating whether or not the shown display A

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

Students also viewed these Programming questions

Question

Identify reasons for choosing qualitative methods.

Answered: 1 week ago