Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1 ) Abstract Class [ 1 5 pts ] Create an abstract class named Vehicle with the following attributes and methods: Attribute ( protected

Task 1) Abstract Class [15 pts]
Create an abstract class named Vehicle with the following attributes and methods:
Attribute (protected, String): model
Constructor: Vehicle(String model)
Abstract method (public void): accelerate()
Abstract method (public void): startEngine()
Abstract method (public void): stopEngine()
Task 2) Interface [10 pts]
Define an interface named Flyable with a method fly(). This interface should be implemented by classes representing vehicles capable of flying.
Task 3) Subclasses [25 pts]
Create two subclasses of Vehicle.
Car: Implement the abstract methods to print a message indicating acceleration, starting the engine, and stopping the engine.
Airplane: Implement the abstract methods to print a message indicating takeoff speed, starting the engine, and stopping the engine. Additionally, Implement the fly() method to print a message indicating the airplane is flying.
Task 4) Polymorphism [40 pts]
Create a VehicleDemo.java class and in the main method:
Create an array of Vehicle objects and initialize it with two instances of Car objects and two instances of Airplane objects.
Iterate through the array and demonstrate polymorphism by calling the accelerate() method on each object.
For objects that implement the Flyable interface, also call the fly() method using downcasting.
Task 5) UML Diagram [10 pts]
Draw the UML diagrams of each class. Show the relationship between classes. Show me the code from task one to task 5 and also the uml diagram

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

what is Pfizer stock value using the Zero-Growth Model?

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago