Question: Chapter 12. of Starting out with JAVA from control structures through objects 6th edition A First Look at GUI Applications 1.Write a class named Car
Chapter 12. of Starting out with JAVA from control structures through objects 6th edition
A First Look at GUI Applications
1.Write a class named Car that has the following fields:
yearModel. The yearModel field is an int that holds the cars year model.
make. The make field references a String object that holds the make of the car.
speed. The speed field is an int that holds the cars current speed.
In addition, the class should have the following constructor and other methods:
Constructor. The constructor should accept the cars year model and make as arguments. These values should be assigned to the objects yearModel and make fields. The constructor should also assign 0 to the speed field.
Accessors. Appropriate accessor methods should get the values stored in an objects yearModel, make, and speed fields.
Create a method called accelerate. The accelerate method should add 7 to the speed each time it is called.
Create a method called brake. The brake method should subtract 5 from the speed each time it is called.
2. Create a GUI with the following elements:
A label and text field showing the yearModel
A label and text field showing the make
A label and text field showing the speed
A button that accelerates the car and displays the new speed
A button that brakes the car and displays the new speed
Extra: What happens if you hit the accelerator twice and the brake three times? Is that how cars work? Can you fix it?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Write a comment for each line within a method (not { or } lines), for each method and for each class
thank you for the help if you can, can you put as many comments you can so i can understand the program well thank you very much for the help
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
