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
Here are some instructions in English. Translate each of them into the Simple Machine language.
Evgen [1.6K]

Answer:

a. LOAD register 3 with the hex value 56

2356

b. ROTATE register 5 three bits to the right.

A503

c. JUMP to the instruction at location F3 if the contents of register 7 are equal to the contents of register 0

B7F3

d. AND the contents of register A with the contents of register 5 and leave the result in register 0

80A5

Explanation:

To translate the English instructions to Machine language we have to consider Appendix C of A Simple Machine Language sheet.

a. LOAD register 3 with the hex value 56

The OP code for LOAD is:

2

Operand is:

RXY

Description is:

LOAD the register R with the bit pattern XY.

In a.

3 represents R

56 represents XY

Now following this we can join OP and Operand together to translate a.

2356

b. ROTATE register 5 three bits to the right

The OP code for ROTATE is:

A

Operand is:

R0X

Description is:

ROTATE the bit pattern in register R one bit to the right X times. Each time place the  bit that started at the low-order end at the high-order end

In b.

5 represents R

three represents X

Now following this we can join OP and Operand together to translate b.

A503

c. JUMP to the instruction at location F3 if the contents of register 7 are equal to the contents of register 0.

The OP code for JUMP is:

B

Operand is:

RXY

Description is:

JUMP to the instruction located in the memory cell at address XY if the bit pattern in  register R is equal to the bit pattern in register number 0.

In c.

7 represents R register

F3 represents XY

Now following this we can join OP and Operand together to translate c.

B7F3

d. AND the contents of register A with the contents of register 5 and leave the result in register 0.

The OP code for AND is:

8

Operand is:

RST

Description is:

AND the bit patterns in registers S and T and place the result in register R

In d.

A represents register S

5 represents register T

0 represents register R

Now following this we can join OP and Operand together to translate d.

80A5

6 0
3 years ago
EASY QUESTIONS! 10 POINTS AND BRAINLIEST FOR BEST ANSWER! PLEASE HELP ANSWER THIS only if you know BOTH ANSWERS!
Illusion [34]

Answer:

chain also why would some knock on their own dang door lol

Explanation:

it's easy indeed

8 0
4 years ago
Read 2 more answers
Code Example 8-1
damaskus [11]

Answer:

Option A: FileNotFoundError

Explanation:

FileNotFoundError is an exception which is thrown when a program fail to open a specified file. The root causes of this type of error can be:

  1. The directory path to locate a target file is wrongly defined in our code due to a typo on the file name or misuse of relative directory path, such as ../ and ./ which denote two different paths.
  2. For some reasons, a target file is misplaced in a wrong directory.

Any one of the above reasons can lead to the exception to be thrown when the file doesn't exist.

6 0
3 years ago
Wap to calculate area and circumference of a circle​
Rainbow [258]

Answer:

To calculate the area of circle πr^2 formula.

And,to calculate the circumference we can use 2πr formula.

5 0
3 years ago
Tyra is peer conferencing about her project with a friend. Tyra's friend provided feedback that Tyra does not agree with. What s
natulia [17]

Answer:

Be kind and thankful

Explanation:

If Tyra does not agree with her friend's feedback, she does not have to say it outrightly to her friend. She has to use softer words to disagree. This is where being kind comes in.

Her friend has made efforts by providing this feedback Even if it is not exactly what she wants to hear. It would be polite for her to say thank you.

Then she has to respectfully disagree to avoid coming off as someone who is totally unreceptive of the opinion of others.

6 0
3 years ago
Other questions:
  • Eye injuries usually occur as a result of all of the following things, EXCEPT:
    13·2 answers
  • In terms of resource utilization, a /an application may require higher local
    8·1 answer
  • A good example of an agency relationship in a hotel is the relationship between a bartender and a server. True False
    6·1 answer
  • In one to two sentences, describe how you would insert a row in a spreadsheet.
    5·2 answers
  • Which of the following is not a valid variable name? 2 myInt 2. return 3. myInteger 4. total3
    6·1 answer
  • (1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Outpu
    7·1 answer
  • The processor of a computer communicates to the other parts of the computer through a code that consists of what?
    9·1 answer
  • What best describes the computer's BIOS (basic input-output system)?
    5·1 answer
  • Section A: A(n) is a collection of information, generally stored as computer files. The information it contains can be stored, u
    10·1 answer
  • Which of these file types does not share info in a spreadsheet?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!