
public class CarTestWithDeepAndShallowCopy {

	public static void main(String[] args) {
		Car c1 = new Car("Ford", 2000);
		Car shallow = c1.shallowCopy();
		System.out.println("the original (c1) and the shallow copy are the same.");
		System.out.println("c1:\n" + c1);
		System.out.println("shallow:\n" + shallow + "\n");

		// A change to the license plate by the shallow copy
		// modifies the license plate of the original
		System.out.println(
				"If the shallow copy modifies its license plate,\nthe license plate of the original is also modified.");
		shallow.changeLicensePlate();
		System.out.println("c1:\n" + c1);
		System.out.println("shallow:\n" + shallow + "\n");

		System.out.println("the original (c1) and the deep copy are the same.");
		Car deep = c1.deepCopy();
		System.out.println("c1:\n" + c1);
		System.out.println("deep:\n" + deep + "\n");
		// A change to the license plate by the deep copy
		// doesn't modify the license plate of the original
		System.out.println(
				"If the deep copy modifies its license plate,\nthe license plate of the original is not modified.");
		deep.changeLicensePlate();
		System.out.println("c1:\n" + c1);
		System.out.println("deep:\n" + deep + "\n");

	}

}