Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java This code answers question 1. import javax.swing.JOptionPane; public class Car { private int Speed = 0; private String Make = Chevy; private int

 In Java image text in transcribed This code answers question 1. import javax.swing.JOptionPane; public class Car { private int Speed = 0; private String Make = "Chevy"; private int yearModel = 2000; public Car (String n, int Model) { Make = n; yearModel = Model; } public int getyearModel () { return yearModel; } public String getMake () { return Make; } public int getSpeed () { return Speed; } public void accelerate () { if (Speed !=90) Speed = Speed +5; } public void brake () { if (Speed !=0) Speed = Speed -5; } } 

Need help with question 2.

1.Write a class named Car that has the following fields: xearModel. The XearModel field is an int that holds the car's 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 car's current speed In addition, the class should have the following constructor and other 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. Accessors. Appropriate accessor methods should get the values stored in an object's 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 earModel 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

=+free to pirate employees from competitors?

Answered: 1 week ago