Page 1 of 1

Write a class to complete the requirements in (a)-(g) below: (a) The class is to be called Car. (b) The class requires t

Posted: Fri Jun 10, 2022 11:56 am
by correctanswer
Write a class to complete the requirements in (a)-(g) below:
(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:
014c2665a7d74530aa5d9d1820c469c4
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.
Copyright notice: This question is copyright The Open University
UK. 014c2665a7d74530aa5d9d1820c469c4
Below is an example test case for this class.
For example: