I want to create a Clock program in java. I have a counter class that takes two parameters, an initial value(integer) and a limit(also an integer). I have another class, a Clock class, which ought to have two parameters (hour and minutes). And this parameters are supposed to be objects of the counter class. How do I create an instance of the counter class in the clock class
Call new
and assign the reference to a variable, of course.
Something like this:
public class Clock {
private Counter counter;
public Clock(int hour, int minutes) {
// don't know what you want here. Can't see how they're related.
this.counter = new Counter(0, 60*hour+minutes);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.