This question concerns a class called Car which is to
be developed to model some aspects of a car.
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:
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.
For example:
This question concerns a class called Car which is to be developed to model some aspects of a car. Write a class to comp
-
- Posts: 43759
- Joined: Sat Aug 07, 2021 7:38 am