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
Draw algorithm and flowchart of multiply A and B​
PolarNik [594]

Answer:what is the a and b we can’t solve it without that

Explanation:

I don’t know if that will help

4 0
3 years ago
Why should you use a named constant for the size of an array?
Brut [27]
I can think of the following reasons:

- Avoid magic numbers. The constant will have a descriptive name like "MAX_MEASUREMENTS" so it can be inferred what the array size really means.

- Avoid duplication. There could be some related code (e.g., code that checks if an index is within the array bounds) that can benefit from using the same constant. Then it makes sense to tie them together such that if you change the constant, you're actually changing all its occurrances.

- Central configuration. By placing all your constants in a centralized place in the code, it is clear to see where your configuration resides. This is easier than having magic numbers scattered throughout the code.
3 0
4 years ago
Ssume that the timeout values for all three protocols
prisoha [69]

Answer:

The explanation of the question is described in the section below.

Explanation:

(a)

Go Back N :

A gives in a maximum of 9 pieces. Typically they will be sent back sections 1, 2, 3, 4, 5 and then re-sent segments 2, 3, 4 and 5.

B sends out 8 ACK's. They are 4 ACKS including 1 series and 4 ACKS with 2, 3, 4 and 5 series amounts.

Selective Repeat :

A sends in such max of 6 bits. Subsequently, segments 1, 2, 3, 4, 5 and earlier re-sent Segments 2 will be sent.

B assigns five ACKs. We are 4our ACKS with numbers 1, 3, 4, 5. However there is one sequence quantity 2 ACK.

TCP :

A assigns in a total of 6 bits. Originally, segments 1, 2, 3, 4, 5 and future re-sent Segments 2 have always been sent.

B sends five ACKs. There are 4 ACKS with either the number 2 series. There has been one ACK with a sequence of numbers 6. Remember that TCP always needs to send an ACK with a sequence number you anticipate.

(b)

This is although TCP utilizes convenient retransmission without searching for the time out.

So, it's the right answer.

4 0
3 years ago
In ancient times what did kings and tribals chiefs use to communicate
mel-nik [20]

Answer:

they used sign language to communicate and also pegion was used to communicate

8 0
3 years ago
If a football player had to use the restroom during a play what do they do?
Artyom0805 [142]
Usually they wait for halftime
4 0
3 years ago
Other questions:
  • A. When executing System.out.println(a1), the toString() method in the Object class is invoked.
    14·1 answer
  • What allows people to create their own radio shows over the internet?
    14·1 answer
  • What version of android did nexus one run?
    14·1 answer
  • What are the constraints for designing small and large files and how these are resolved in different file system
    7·1 answer
  • Which of the following is not a responsibility of a member of society?
    14·1 answer
  • What is the different between 32bit anf 64 bit verision​
    11·1 answer
  • 1. What was the very first “photo-realistic CGI character” to appear on-screen in a movie (released in 1985)?
    8·2 answers
  • Discuss the core technologies and provide examples of where they exist in society. Discuss how the core technologies are part of
    14·1 answer
  • How do you create a turtle in python again-
    6·1 answer
  • List at least three kinds of harm a company could experience from electronic espionage or unauthorized viewing of confidential c
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!