Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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
Check Mark
Knowledge Booster
Background pattern image
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
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education