Question
Whenever I try to compile my code, it says error: call to super must be first statement in constructor super(setTime) Can someone please help
Whenever I try to compile my code, it says "error: call to super must be first statement in constructor
super(setTime)" Can someone please help me with this, thank you!
public class CMilClock extends CClockType { private int milHours; private int milSec; public CMilClock() { this.milHours = 0; this.milSec = 0; } public CMilClock(int milHours, int milSec) { setTime(milHours, milSec); } public void setTime(int milHours, int milSec) { // TODO change the member variable values in base class and super class super(setTime); this.milHours = milHours; this.milSec = milSec; } public int getHour() { return this.milHours; } public int getStdHr() { return super.getHour(); } public void printTime(){ System.out.println(this.milHours + ":" + this.milSec); super.printTime(); } public static void main(String [] argv){ CMilClock myClock = new CMilClock(1230, 10); myClock.printTime(); CClockType youClock = new CMilClock(1230, 10); youClock.printTime(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started