(a) The class is to be called Car. (b) The class requires two private fields called year of type int and make of type St

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
correctanswer
Posts: 43759
Joined: Sat Aug 07, 2021 7:38 am

(a) The class is to be called Car. (b) The class requires two private fields called year of type int and make of type St

Post by correctanswer »

(a) The class is to be called Car.
(b) The class requires two private fields called year of type int and make of type String.
(c) Add a public constructor to the class that takes two parameters. The first parameter is of type int and the second parameter is of type String. Use the first parameter to set the year field, and the second parameter to set the make field.
(d) Write standard getter methods for the two fields.
(e) Write standard setter methods for the two fields.
(f) Write a public method called toString that takes no parameters and returns a string of the following form:
The year and make should be replaced by the actual year and make of the car.
(g) Write a public method with the signature equals(Car) that returns true if the fields of the actual parameter have the same values as the fields of this object, and returns false otherwise.
Register for solutions, replies, and use board search function. Answer Happy Forum is an archive of questions covering all technical subjects across the Internet.
Post Reply