subject

Write a class named car that has the following fields: • yearmodel: 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. • 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 arguments. 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 should be implemented to access the values stored in the object's yearmodel, make, and speed fields. • accelerate: the accelerate method should add 5 to the speed field when it is called. • brake: the brake method should subtract 5 from the speed field each time it is called. demonstrate the class in a program that contains a car object, and then calls the accelerate method five times. after each call to the accelerate method, get the current speed of the car and print it on a separate line. then, call the brake method five times, each time printing the current speed of the car on a separate line.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:30
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
question
Computers and Technology, 23.06.2019 20:00
Match the file formats with the types of multimedia they can store
Answers: 2
question
Computers and Technology, 24.06.2019 07:30
John recently worked on a project about various programming languages. he learned that though procedural language programs are useful, they have disadvantages too. what is a disadvantage of programs written in procedural languages? a. programs do not represent data complexity. b. programs take more time to execute. c. programs are prone to security threats. d. programs do not interface with multiple platforms.
Answers: 3
question
Computers and Technology, 24.06.2019 10:30
Which of the following types of software is most applicable to the promotion of new products through advertising? a.databases b. spreadsheets c. web design programs d. word processing tools
Answers: 2
You know the right answer?
Write a class named car that has the following fields: • yearmodel: the yearmodel field is an int...
Questions
question
History, 07.10.2019 07:30
Questions on the website: 13722361