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
Create an application named TestSoccerPlayer that instantiates and displays a SoccerPlayer object. The SoccerPlayer class contai
frutty [35]

Answer:

public class TestSoccerPlayer {

   public static void main(String[] args) {

       SoccerPlayer playerOne = new SoccerPlayer("Rinco",9,16,22);

       System.out.println("The player of the season is "+playerOne.getName()+" His Jessey Number is "+playerOne.getJerseyNum()

       +" In the 2019/2020 season he scored and total of "+playerOne.getGoalsScored()+" and "+

               playerOne.getAssists()+" Asists");

   }

}

See the SoccerPlayer class with the feilds and methods (constructor, getter and setters) in the explanation section

Explanation:

public class SoccerPlayer {

   private String name;

   private int jerseyNum;

   private int goalsScored;

   private int assists;

   public SoccerPlayer(String name, int jerseyNum, int goalsScored, int assists) {

       this.name = name;

       this.jerseyNum = jerseyNum;

       this.goalsScored = goalsScored;

       this.assists = assists;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public int getJerseyNum() {

       return jerseyNum;

   }

   public void setJerseyNum(int jerseyNum) {

       this.jerseyNum = jerseyNum;

   }

   public int getGoalsScored() {

       return goalsScored;

   }

   public void setGoalsScored(int goalsScored) {

       this.goalsScored = goalsScored;

   }

   public int getAssists() {

       return assists;

   }

   public void setAssists(int assists) {

       this.assists = assists;

   }

}

5 0
3 years ago
If numbers are sorted from the lowest number to the highest number, they are in _____ order.
pogonyaev
They ard in ascending order
5 0
3 years ago
Read 2 more answers
The items below list workers' e-mail practices. Select the practices that are appropriate for the use of e-mail in the workplace
Maurinko [17]
The appropriate behaviours are:

<span>- Dylan's e-mails include a signature with his name, e-mail address, title, mailing address, and phone number.  
-Isabel uses Reply when responding to the messages she receives, so that the thread of previous messages is included.
-Nadine uses spell check instead of proofreading to reduce mistakes and save time.
-Tomas makes his e-mail messages brief.


The all correspond to the needs of a formal communication: brief and formal, and one that documents everything so that in a case of a doubt, people can look into what happened in the past and understand where the problems come from.

What should not happen:

</span><span>
-Garrett wants to make sure his messages are read first, so he marks all the e-mails he sends as urgent.
-When a message is extremely important, Ana writes in all capital letters.
-When Marissa wants to make a point, she uses lots of exclamation marks to get her message across.

Those actions show more informal behaviours, and all capitals are never welcomed at work.
</span>
7 0
3 years ago
HELP!! **
andrew11 [14]

Answer:

sry i usually dont play games

sry

plz mark me brainlist pls

7 0
3 years ago
Complete the sentence about entering and editing data in a cell in a spreadsheet.
Cloud [144]

Answer:

1. Select the cell, click and start typing

2. Select the cell, click and start typing

Explanation:

To enter data in a cell in a spreadsheet, select the cell, click and start typing.

To overwrite data in a cell, select the cell, click and start typing.

A spreadsheet is an application that is used for entering, organizing, analyzing, interpreting and storing data. It a relatively simple application and an example is Microsoft Excel. The easiest way to enter data into a spreadsheet is to select the cell, click and start typing. Overwriting an already existing data can be done in the same manner in which data is entered into a cell - selecting the cell, clicking and start typing.

3 0
3 years ago
Read 2 more answers
Other questions:
  • What technological innovation was the key factor driving the booming economy?
    8·1 answer
  • Give reasons why mind-mapping software is important to project development.
    14·1 answer
  • Which of the following best describes open source software?
    7·2 answers
  • The approved detail design resulting from the __________ serves as a basis for making the decision to begin production.
    8·1 answer
  • Which of the following is true about simulation games? A. Simulation games involve competing in a sport against other players. B
    10·2 answers
  • How can ascii be used to represent characters in computer system
    7·1 answer
  • What word describes a violation of copyright laws? What rights do copyright holders have over their work of art
    5·2 answers
  • which of these tools stick to the edge of an image, thus making it easy to select the shape of an image
    6·1 answer
  • What are ways to access Tasks view in Outlook? Check all that apply. Select To-Do List or Task Folder. View daily task lists in
    8·2 answers
  • Select the correct answer from each drop-down menu. The following diagram shows four resistors. What is the effective resistance
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!