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
Yanka [14]
4 years ago
15

Design a class named Car that has the following fields:

Computers and Technology
1 answer:
snow_tiger [21]4 years ago
4 0

Answer:

// The class car is defined

public  class Car {

  // instance variable yearModel

  private int yearModel;

  // instance variable make

  private String make;

  // instance variable speed

  private int speed;

 

  // empty constructor

  // with instances inside it

  // the instances are from the question

  public Car(){

      yearModel = 2000;

      make = "Nissan";

      speed = 4;

  }  

  // overloaded constructor

  // constructor defined with three arguments

  public Car(int yearModel, String make, int speed) {

      // the arguments are assigned to the object's variable

      this.yearModel = yearModel;

      this.make = make;

      this.speed =speed;

  }

  // setter(mutator) method

  public void setYearModel(int yearModel){

      this.yearModel = yearModel;

  }

  // setter(mutator) method

  public void setMake(String make){

      this.make = make;

  }

  // setter(mutator) method

  public void setSpeed(int speed){

      this.speed = speed;

  }

  // getter(accessor) method

  public int getYearModel(){

      return yearModel;

   }

  // getter(accessor) method

  public String getMake(){

      return make;

   }

  // getter(accessor) method

  public int getSpeed(){

      return speed;

   }  

  // toString is override to display the car object properties

  public String toString(){

      return "Car's year model: " + getYearModel() + ", make: " + getMake() + ", speed: " + getSpeed();

  }

}

Explanation:

The code is well commented.

You might be interested in
Filmmakers must often establish information quickly in a film in order to give the audience context for the plot. In this film,
Dimas [21]
One thing evident about the two individuals is that Don and Lina are famous. The filmmaker, in the beginning uses the announcer to introduce them as "known all over the world." Another thing to note is that Don and Lina personified themselves a certain way to their fans. The announcer believed sincerely that they were courting. While the announcer played a huge part in giving the audience information that Don and Lina were courting, the filmmaker made sure that audience (crowd in the scene) played a vital part too. Once Don and Lina posed for a picture together, the crowd went wild. This implies that the audience believed that they were together.
8 0
3 years ago
Which online resource is usually not free?
Andrej [43]

Answer:

educational tutoring

Explanation:

7 0
3 years ago
Read 2 more answers
List three tacos there are several from the opening page of the help and support center.
s344n2d4d5 [400]
Mexican tacos sascSDV
8 0
4 years ago
Which one of the following sstatements suggests a good method
PilotLPTM [1.2K]
The 2nd onnnnneeeeeee
7 0
3 years ago
Which two devices are paired to create a memory cell? what term is used to describe this common form of computer memory? (2 poin
elena-14-01-66 [18.8K]

A transistor and A capacitor

<h3>What are transistors and capacitors?</h3>
  • Transistors are semiconductor devices used to amplify or switch electronic signals.
  • Inductors are passive electrical devices in electrical circuits for their property of inductance.
  • While a capacitor opposes changes in voltage, an inductor opposes changes in current.

To learn more about it, refer

to https://brainly.in/question/413163

#SPJ4

6 0
2 years ago
Other questions:
  • 1. What conversion factor should be used to convert from Gigaliters to liters?
    14·1 answer
  • Importance of being having data on hand​
    7·1 answer
  • Using a WHILE loop write a program that asks the user to guess your favorite number. The program should end when the user guesse
    11·1 answer
  • Text can be inserted into a presentation by
    7·1 answer
  • Which tool is best used to test an electrical current for a power source?
    8·1 answer
  • The requester of sensitive information should not receive access just because of his or her clearance, position, or rank. The re
    15·1 answer
  • Which of these personal protective equipment items prevents injury from falling objects ?
    15·1 answer
  • Which of the following is considered a basic task in the context of computer operations? a. Connecting to the Internet b. Natura
    6·1 answer
  • Very complex type of processing is carried out by a which computer.
    11·1 answer
  • This code is supposed to accept a word as input, and then print that word to the screen.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!