I am using Eclipse to right there It is coming up with an error within the switch statement saying that the Clock.* has not been initialized. it says Description "The local variable Clock may not have been initialized" but doesn't that happen when i do "Stopwatch Clock;" I am still getting used to Java. I am taking some C++ classes and i was trying to find out if i can this to work in java like i did in C++
public class start {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int a=1;
int c=0;
while(c!=5) {
System.out.print("1-Start, 2-Stop, 3-Reset, 4");
System.out.println("-Display, 5-Quit");
c=sc.nextInt();
Stopwatch Clock;
switch(c) {
case 1: Clock.Start();break;
case 2: Clock.Stop();break;
case 3: Clock.Reset();break;
case 4: Clock.Display();break;
} //end of switch for calling stopwatch
}//end of while loop once int 5 comes in
}//end of main
}//end of class
Stopwatch.java
public class Stopwatch {
private //vars go here.
Stopwatch() {
//sets var to =0
}
//----------------------------------------------------
public void Start() {
//start clock
}
//----------------------------------------------------
public void Stop() {
//stop clock
}
//----------------------------------------------------
public void Reset() {
//reset clock
}
//----------------------------------------------------
public void Display() {
//call output for format of dispay
}
//----------------------------------------------------
private void Output() {
//put clock to screen
}
}