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
Paraphin [41]
3 years ago
6

Write a class named Car that has the following fields: yearMode1. The yearModel field is an int that holds the car's year model.

make. The make field is a String object that holds the make of the car, such as "Ford" "Chevrolet", "Honda", etc. speed. The speed field is an int that holds the car's current speed. In addition, the class should have the following methods . Constructor. The constructor should accept the car's year model and make as ments. These values should be assigned to the object's yearModel and make fields. The constructor should also assign 0 to the speed field. Accessor. The appropriate accessor methods get the values stored in an object's yearModel, make, and speed fields. , accelerate. The accelerate method should add 5 to the speed field each time it is called _________. brake. The brake method should subtract 5 from the speed field each time it is called.
Computers and Technology
2 answers:
Gekata [30.6K]3 years ago
8 0
Skeh wkf ahfmroztdjdy
Dmgk
Ann Write a class named Car that has the following fields: yearMode1. The yearModel field is an int that holds the car's year model. make. The make field is a String object that holds the make of the car, such as "Ford" "Chevrolet", "Honda", etc. speed. The speed field is an int that holds the car's current speed. In addition, the class should have the following methods . Constructor. The constructor should accept the car's year model and make as ments. These values should be assigned to the object's yearModel and make fields. The constructor should also assign 0 to the speed field. Accessor. The appropriate accessor methods get the values stored in an object's yearModel, make, and speed fields. , accelerate. The accelerate method should add 5 to the speed field each time it is called _________. brake. The brake method should subtract 5 from the speed field each time it is called.
Harlamova29_29 [7]3 years ago
8 0
<h2>Answer:</h2>

//Write the class definition for the class Car

public class Car {

   //Declare the instance variables(fields)

   int yearModel;

   String make;

   int speed;

   

   //Declare the constructor: Make sure the constructor has  

   //the same name as the name of the class - Car.

   //The constructor receives two parameters - yearModel and make.

   //The parameters are then assigned to their respective fields.

   //The speed field is given a value of zero.

   public Car(int yearModel, String make){

       this.yearModel = yearModel;

       this.make = make;

       this.speed = 0;

   }

   //Accessor method - get - for the yearModel

   //returns the yearModel of the car

   public int getYearModel() {

       return yearModel;

   }

   //Accessor method - get - for the make

   //returns the make of the car

   public String getMake() {

       return make;

   }

   //Accessor method - get- for the speed

   //returns the speed of the car

   public int getSpeed() {

       return speed;

   }

   

   //Method accelerate() to increase the speed of the car by 5

   //each time it is called

   public void accelerate(){

       this.speed += 5;

   }

   

   //Method brake() to decrease the speed of the car by 5

   //each time it is called

   public void brake(){

       this.speed -= 5;

   }

   

}    //End of class declaration

<h2>Explanation:</h2>

The code above has been written in Java. It contains comments explaining the code. Please go through the comments. The actual lines of code that are executable are written in bold-face to distinguish them from the comments.

You might be interested in
For local travel addresses and street names should be
saul85 [17]
Capitalized  and properly spelled 

8 0
3 years ago
Consider the following program:
Nostrana [21]

Answer:

this would be answer D

Explanation:

7 0
3 years ago
Mike needs to write the primary objectives of a project in a project plan. In which section should he write them?
pochemuha
D because you are always supposed to use your schedule
5 0
3 years ago
Como hago para poner brainly en español???
Lelu [443]
Mentely es eso espero q te ayude :)
4 0
3 years ago
Read 2 more answers
Can someone URGENTLY help me with my java code (I WILL GIVE BRAINLIEST)!? Ive been working on it for hours and its not working!
vovikov84 [41]

Answer:

Private ListNode intel size

7 0
2 years ago
Other questions:
  • Which of the following represent typical account fees?
    7·1 answer
  • What is one way to process your thoughts about the information you are reading?
    14·2 answers
  • What is the maximum number of communication paths for a team of twenty people?
    5·1 answer
  • When a range of IP addresses is set aside for client devices, and one of these IPs is issued to these devices when they request
    14·1 answer
  • If you delete an imessage does the other person see it
    12·1 answer
  • Choose all items that represent characteristics of an HTML element. used to include additional information in an attribute consi
    15·1 answer
  • Provide a few examples of how cryptography actually secures data.
    8·1 answer
  • The product of two integers is -180 if one of them is 12 find the other​
    14·1 answer
  • What is the missing line of code?
    7·1 answer
  • Which is a benefit of peer-to-peer networking?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!