Do the following in Java and provided source code with screenshots of correct output to show it works! (New Solution without AI) 1. Create an interface Vehicle that contains three void, abstract methods named Start, Stop and Change Speed. 2 .Create an Airplane class (not abstract) that uses the Vehicle interface in Q1. The code for all methods should print simple messages to the screen using System.out.println(). Add an integer speed variable that is changed using the Change Speed method. ChangeSpeed adds 5 to the speed each time it is called. Create a default constructor that sets the initial speed to 0. Don't create other constructors or any setter/getter methods. 3. Create an abstract class Car that also uses the Vehicle interface in Q1 and has three variables, Year, Make, and Speed. Include the following: One constructor that accepts the car's year and make as arguments. The constructor should also assign 0 to the speed variable. Do not create other constructors. Create a void method sound but leave it unimplemented. Create a variable Count that keeps track of the number of car instances. When each new car is created, the counter should increment by 1. Create a getCount method that returns the number of car instances held in the Count variable. Don't implement the Vehicle interface methods. Don't implement any setters/getters. 4.Create a class SportsCar that inherits from the Car class in Q3. Include the following: A variable Roof that holds the type of roof (Ex: Convertible, Hard-Top, Soft-Top) A variable Doors that holds the car's number of doors (Ex: 2, 4) Implement the Change Speed method to add 20 to the speed each time it is called. Add exception handling to the Change Speed method to keep the speed under 65. Implement the sound method to print, "broooom," to the screen. Create one constructor that accepts the car's roof, doors, year and make as arguments and assigns the values appropriately. Do not create any other constructors. The interface methods should print simple messages to the screen using System.out.println(). 5.Create a driver class Playground that contains the function, public static void main(String[] args) {}. Create 2 SportsCar and 2 Airplane instances using their constructors. Add all 4 instances into a single array called, "elements." Create a loop that examines each element in the array, "elements." If the elements item is a SportsCar, run the sound method and if the item is an Aeroplane, run it's ChangeSpeed method. Run the getCount() method (created in Q3) to display how many total cars were created.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

Do the following in Java and provided source code with screenshots of correct output to show it works! (New Solution without AI)

1. Create an interface Vehicle that contains three void, abstract methods named Start, Stop and Change Speed.

2 .Create an Airplane class (not abstract) that uses the Vehicle interface in Q1. The code for all methods should print simple messages to the screen using System.out.println(). Add an integer speed variable that is changed using the Change Speed method. ChangeSpeed adds 5 to the speed each time it is called. Create a default constructor that sets the initial speed to 0. Don't create other constructors or any setter/getter methods.

3. Create an abstract class Car that also uses the Vehicle interface in Q1 and has three variables, Year, Make, and Speed. Include the following:

  • One constructor that accepts the car's year and make as arguments. The constructor should also assign 0 to the speed variable. Do not create other constructors.
  • Create a void method sound but leave it unimplemented.
  • Create a variable Count that keeps track of the number of car instances. When each new car is created, the counter should increment by 1.
  • Create a getCount method that returns the number of car instances held in the Count variable.
  • Don't implement the Vehicle interface methods. Don't implement any setters/getters.

4.Create a class SportsCar that inherits from the Car class in Q3. Include the following:

  • A variable Roof that holds the type of roof (Ex: Convertible, Hard-Top, Soft-Top)
  • A variable Doors that holds the car's number of doors (Ex: 2, 4)
  • Implement the Change Speed method to add 20 to the speed each time it is called.
  • Add exception handling to the Change Speed method to keep the speed under 65.
  • Implement the sound method to print, "broooom," to the screen.
  • Create one constructor that accepts the car's roof, doors, year and make as arguments and assigns the values appropriately. Do not create any other constructors.
  • The interface methods should print simple messages to the screen using System.out.println().

5.Create a driver class Playground that contains the function, public static void main(String[] args) {}.

  • Create 2 SportsCar and 2 Airplane instances using their constructors.
  • Add all 4 instances into a single array called, "elements."
  • Create a loop that examines each element in the array, "elements." If the elements item is a SportsCar, run the sound method and if the item is an Aeroplane, run it's ChangeSpeed method.
  • Run the getCount() method (created in Q3) to display how many total cars were created.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,