Question: I need for Java. For this exercise, you need to work on your own. In this exercise you will write the implementation of the pre
I need for Java.
For this exercise, you need to work on your own. In this exercise you will write the implementation of the pre written implementation of the class CAR. The class CAR has the following data and methods listed below: Data fields: A String model that stores the car model, and an int year that stores the year the car was built. Default constructor Overloaded constructor that passes values for both data fields. Method getModel that returns the car's model. Method got Year that returns the year the car was built. Method setModel that re sets the value of the car model Method setYear that re-sets the year. Method compare that passes an object of the Car class and returns true if the calling object is equal to the parameter object, and false otherwise. Method print that prints both the model and the year (any format). And here's the UMl for the object The CAR class implementation has been written for you as well as the structure for the calling program CARDEMO. You will complete the exercise by writing the Java statements for each of the commented sections. You should be able to run the program after compiling. Create an object of the class Car named ferrari. Use the print method to print all information about the ferrari object. Create an object of the class Car named cobra, passing parameters "Cobra" and 1967. Print information about the Cobra object using get methods. Change the model of the cobra object to "Shelby Cobra". Change the year of the cobra object to 1963. Use the print method to print out information about the cobra. Use an if/else statement and the method compare to compare the ferrari and with the cobra obj. Output "Same" if they are the same, or "Different" if they are different
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
