1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Furkat [3]
3 years ago
11

Create a program that simulates a race between several vehicles. Design and implement an inheritance hierarchy that includes Veh

icle as an abstract superclass and several subclasses
Computers and Technology
1 answer:
Amanda [17]3 years ago
6 0

Answer:

Explanation:

The following program is written in Java. Since there was not much information provided in the question I created a Vehicle superclass with a couple of subclasses for the different types of vehicles (motorcycle, sedan, truck). Each one having its own unique attributes. The vehicle class also has an attribute for the position of the vehicle in the race.

class Vehicle {

   int year, wheels, position;

   public Vehicle(int year, int wheels, int position) {

       this.year = year;

       this.wheels = wheels;

       this.position = position;

   }

   public int getYear() {

       return year;

   }

   public void setYear(int year) {

       this.year = year;

   }

   public int getWheels() {

       return wheels;

   }

   public void setWheels(int wheels) {

       this.wheels = wheels;

   }

   public int getPosition() {

       return position;

   }

   public void setPosition(int position) {

       this.position = position;

   }

}

class Motorcycle extends Vehicle {

   String manufacturer;

   double speed;

   public Motorcycle(int year, int wheels, int position) {

       super(year, wheels, position);

   }

   public Motorcycle(int year, int wheels, int position, String manufacturer, double speed) {

       super(year, wheels, position);

       this.manufacturer = manufacturer;

       this.speed = speed;

   }

   public String getManufacturer() {

       return manufacturer;

   }

   public void setManufacturer(String manufacturer) {

       this.manufacturer = manufacturer;

   }

   public double getSpeed() {

       return speed;

   }

   public void setSpeed(double speed) {

       this.speed = speed;

   }

}

class Sedan extends Vehicle {

   int passengers;

   String manufacturer;

   double speed;

   public Sedan(int year, int wheels, int position) {

       super(year, wheels, position);

   }

   public Sedan(int year, int wheels, int position, int passengers, String manufacturer, double speed) {

       super(year, wheels, position);

       this.passengers = passengers;

       this.manufacturer = manufacturer;

       this.speed = speed;

   }

   public int getPassengers() {

       return passengers;

   }

   public void setPassengers(int passengers) {

       this.passengers = passengers;

   }

   public String getManufacturer() {

       return manufacturer;

   }

   public void setManufacturer(String manufacturer) {

       this.manufacturer = manufacturer;

   }

   public double getSpeed() {

       return speed;

   }

   public void setSpeed(double speed) {

       this.speed = speed;

   }

}

class Truck extends Vehicle {

   int passengers;

   String manufacturer;

   double speed;

   public Truck(int year, int wheels, int position) {

       super(year, wheels, position);

   }

   public Truck(int year, int wheels, int position, int passengers, String manufacturer, double speed) {

       super(year, wheels, position);

       this.passengers = passengers;

       this.manufacturer = manufacturer;

       this.speed = speed;

   }

   public int getPassengers() {

       return passengers;

   }

   public void setPassengers(int passengers) {

       this.passengers = passengers;

   }

   public String getManufacturer() {

       return manufacturer;

   }

   public void setManufacturer(String manufacturer) {

       this.manufacturer = manufacturer;

   }

   public double getSpeed() {

       return speed;

   }

   public void setSpeed(double speed) {

       this.speed = speed;

   }

}

You might be interested in
Which type of data is generally stored in different file formats, such as text files, spreadsheets, and so on?
zepelin [54]

Answer:

Plain text storage (eg, CSV, TSV files)

Sequence Files.

Avro.

Parquet.

3 0
2 years ago
Read 2 more answers
In Revit, BIM provides a variety of model information. Which piece of information is not offered by BIM? Select Answer A) Payrol
gizmo_the_mogwai [7]

Answer:

yeet my points into my wallet i need brainliest for points plzz

i actually think scheduling im 11 so i dont know dude

4 0
3 years ago
The amount of magnification gained from the extension tube is dependent on the focal length of the lens.
jenyasd209 [6]
The statement, "The amount of magnification gained from the extension tube is dependent on the focal length of the lens" is true.
6 0
3 years ago
Read 2 more answers
Why you think Operating System is pivotal in teaching and learning.
Elina [12.6K]

Answer:

An Operating System is pivotal in teaching and learning because:

1. It enables computer users to communicate with the hardware.

2. To run any computer programme successfully, the Operating System is basic.

3. It provides a smooth interface for teachers to use video conferencing or other conferencing systems in teaching their students.

4. The OS enables the launching of other learning packages on a computer system.

5. Students can install learning apps on their systems with the help of the OS.

Explanation:

An Operating System is a software which brings about easy communication with the hardware and enablea other programs to run on the computer easily. It provides basic functionality in systems were they are installed.

6 0
2 years ago
_____ are software systems designed to support interoperable machine-to-machine interaction over a network.
BlackZzzverrR [31]

Answer:

A Web service

Explanation:

A Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format

8 0
2 years ago
Other questions:
  • The sequence of folders to a file or folder is known as its _______.
    6·1 answer
  • Which of the following statements correctly describe a computer program?
    11·2 answers
  • Columns can be added to a page in the page layout tab in the blank grouping
    10·2 answers
  • When you respond to an email from your bank that asks you to verify your account information, you may become a victim of a _____
    14·1 answer
  • What term is defined as private data placed in a packet with a header containing routing information that allows the data to tra
    13·1 answer
  • Create a class called Book with the following properties using appropriate data types: Title, Author, numberOfPages, Create a se
    12·1 answer
  • Which of the following extends a network over a large geographic area by connecting local area networks together?
    14·2 answers
  • Is anyone else having issues with brainly not working? Everytime I click on a answer it only comes up with the 7 month trail thi
    12·1 answer
  • Introduce yourself by following the rule
    5·1 answer
  • This is a graded practice activity. This is not an actual quiz.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!