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
What is the name given to the amount that a particular camera’s lens opens?
RSB [31]

Answer:

The correct answer to the following question will be "Aperture".

Explanation:

  • An Aperture is an opening or a hole by which light passes. More primarily, an optical system's aperture and focal length determine a package of rays cone angle that reaches a focus throughout the image plane.
  • Aperture is also the name given to the volume that the lens of a given camera opens.
  • In other contexts, the word aperture can also be used to indicate a system that blocks light outside of a given region. For example, in astronomy, a photometric aperture around a star typically correlates to a circular window across the picture of a star under which the intensity of light is assumed.

The other three options will not be the answer of the given question because, ISO (The ISO is an international standard-setting body consisting of members from different organizations and national standards), Resolution (the level of determination) and Shutter speed (the time frame the film or digital sensor is exposed to light inside of the camera when a camera shutter is open while taking a photo).

So, Aperture is the right answer.

7 0
3 years ago
18. Hard skills can be used on almost any job. (3 points)<br> A. True<br> B. False
Step2247 [10]
I think False brcause tgere are some jobs that dont need hard skills but at the same time am not really sure
6 0
3 years ago
Read 2 more answers
Imagine you’re at lunch. Your nose smells pizza. Your legs move over to where hot lunch is being served. You have to balance the
fiasKO [112]

Answer:

Organization of Life

7 0
3 years ago
Read 2 more answers
Jose needs to find out how to delete cells from his workbook.
Komok [63]

Answer: F1

Explanation:

8 0
3 years ago
Read 2 more answers
How to change default search engine in internet explorer 11?
nordsb [41]
<span>1.Open Internet Explorer.
2.In the top right corner of your browser, click the down arrow in the search box.
3.Click Find More Providers.
4.Click Google.
5.Check the box next to "Make this my default search provider.
6."Click Manage Search Providers.
<span>7.Click Add.

hope this helps :D</span></span>
5 0
3 years ago
Other questions:
  • The following declaration appears in a program: short totalPay, basePay = 500, bonus = 1000; The following statement appears in
    9·1 answer
  • Which of the following is true about images that are arranged in a collumn
    9·1 answer
  • A _____ attack keeps the target so busy responding to a stream of automated requests that legitimate users cannot get in
    9·1 answer
  • What is the most important trait of the first pilot project in the AI Transformation Playbook?
    10·1 answer
  • Discuss at least two challenges students face when conducting research on the Internet.
    7·2 answers
  • Create another method: getFactorial(int num) that calculates a Product of same numbers, that Sum does for summing them up. (1,2,
    7·1 answer
  • Please help me!!!!!!!!
    5·2 answers
  • I am a mouse, but im not a mouse.<br><br> What am I?
    12·1 answer
  • Tascake Gets Free Brainliest Because he didnt get it<br><br> Tascake Heres Brainliest
    6·2 answers
  • Modern life is not possible if computer stops working? Give your opinion<br>​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!