A class named Clock has two instance variables: hours (type int) and isTicking (type boolean) Write a constructor that takes a reference to an existing Clock object as a parameter and copies that object's instance variables to the object being created Your task: Write a Clock constructor that makes this possible. Just write this constructor-don't write the whole class or any code outside of the class! 1-ublic ClockOt this.hours hours 3 this.isTicking - isTicking; 75 characters 5000 maximum Previous Submissions xCode Analysis: Logic Error(s) Remarks and Hints: The constructor should take one parameter. Unexpected identifiers: this Your assignment seems to be backwards.

Respuesta :

ijeggs

Answer:

public Clock (Clock c)

{

hours = c.hours;

isTicking = c.isTicking;

}

Explanation:

Since the name of the Java class is called Clock, the constructor must have that same name, so we start by declaring the constructor as public Clock (Clock c) with a clock parameter. Within the contructor body we assign the variables hours and isTicking to the respective member feilds