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]
4 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]4 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]4 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
(Synchronized threads) Write a program that launches 1000 threads. Each thread adds a random integer (ranging from 1 to 3, inclu
Goshia [24]

Using the knowledge in computational language in JAVA it is possible to write a code that organizes and synchronizes the programs that will run on the computer.

<h3>Writting the JAVA code as:</h3>

<em>import java.util.concurrent.ExecutorService;</em>

<em>import java.util.concurrent.Executors;</em>

<em>public class Main</em>

<em>{</em>

<em>Integer sum=new Integer(0);</em>

<em>Main(){</em>

<em>ExecutorService e=Executors.newFixedThreadPool(1000);</em>

<em>final Sum s = new Sum();</em>

<em>for(int i=0;i<1000;i++){</em>

<em>e.execute(s);</em>

<em>}</em>

<em>e.shutdown();</em>

<em>while(!e.isTerminated()){</em>

<em>}</em>

<em>System.out.println(sum);</em>

<em>}</em>

<em>public static void main(String[]args){</em>

<em>new Main();</em>

<em>}</em>

<em>class Sum implements Runnable{</em>

<em>public void run() {</em>

<em>m();</em>

<em>}</em>

<em>public void m(){</em>

<em>sum=sum+1;</em>

<em>}</em>

<em>}</em>

<em>}</em>

See more about JAVA at brainly.com/question/12978370

#SPJ1

4 0
2 years ago
A(n) _____ is a network connection device that can build tables that identify addresses on each network.
Neko [114]

Answer:

Dynamic Router

Explanation:

5 0
3 years ago
Where should fire extinguishers be stored on a boat?
fomenos

<span>Fire extinguishers should be stored in a boat at the engine area and near the operator. A fire extinguisher should be put near the engine because the engine of the boat is a fire hazardous place and this is the area where a fire could start.  The fire extinguisher should be installed properly using a mounting bracket to hold the extinguisher in place. There are different types of extinguishers that should be installed in the boat, these are type A, B, and C extinguishers. Type A extinguishers can turn off the fire caused by combustible solids like wood and paper. Type B extinguishers can turn off fire caused by gasolines, oil, and greases. While Type C extinguishers can turn off fire caused by an electrical problem.</span>

5 0
3 years ago
Add me on Pokemon go, my trainer code is 5584 3300 5313
evablogger [386]

Answer:

no want it

Explanation:

7 0
3 years ago
What would be a standard way for anyone outside an agile team( for example, delivery partner partner of the account, head of the
musickatia [10]

Answer:

He/She can refer the physical/digital kanboard ,which is maintained by the team

7 0
3 years ago
Other questions:
  • Suppose you wish to write a method that returns the sum of the elements in partially filled array. Which is the best choice for
    6·1 answer
  • Briefly explain the following terms and concepts:
    8·2 answers
  • Divide (10x^3 + 19x^2 + x - 7) by (5x + 2)​
    11·1 answer
  • Computer hardware without software is usless and compyrersoftware without hardware is meaningless discuss
    6·1 answer
  • What is considered to be the core of the Unix operating system ?
    14·1 answer
  • This finding maximum number function will keep on going until we reach at the last value
    12·1 answer
  • What is the output?
    12·1 answer
  • Any action that causes harm to your computer is called a
    15·1 answer
  • Brainliest For Tascake Because People Texted Before Tascake Could<br><br> Hurry Tascake
    13·2 answers
  • What kind of charger can i use for this
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!