This exercise demonstrates using a reference parameter to pass data back to the calling method. Suppose you want a Car5 class to include a method with this heading:
public boolean copyTo(Car5 newCar)
This method is supposed to be called by an existing Car5 object with an argument to a new Car5 object. If any of the calling car’s instance variables has not been initialized, the desired method should not try to modify any of the new car’s instance variable values, and the method should return false. Otherwise, the method should copy all of the calling car’s instance variable values into the new car and return true. Here’s a driver that illustrates the usage:
/***************************************************************** Car5Driver.java* Dean&Dean** This class is a demonstration driver for the Car5 class.****************************************************************/public class Car5Driver{public static void main(String[] args){Car5 annaCar = new Car5();Car5 nickCar = new Car5();System.out.println(annaCar.copyTo(nickCar));annaCar = new Car5("Porsche", 2006, "beige");System.out.println(annaCar.copyTo(nickCar));} // end main} // end class Car5DriverOutput:
falsetrue
Write the code for the desired copyTo method.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.