I have a stopwatch program and the last of the code has to be a static class
can someone help running out of time.
I've tried all i know examples aren't helping.
Here is the code I've written.
I hope someone can help. TY...
// import java.io package and utility packages
import java.io.*;
import java.util.*;
class Stopwatch{
public void start() {
GregorianCalendar now = new GregorianCalendar();
startTime = now.getTimeInMillis();
}
public void showElapsedTime() {
GregorianCalendar now = new GregorianCalendar();
long currTime = now.getTimeInMillis();
long difference = (currTime - startTime)/1000;
System.out.print(difference);
System.out.println(" seconds have elapsed.");
}
//declared outside of all methods
private long startTime;
}
class Irritating_stopwatch {
public static void main(String arg[]) throws Exception {
BufferedReader keyboard = new BufferedReader(
new InputStreamReader(System.in));
Stopwatch timer = new Stopwatch();
Counter countDown = new Counter();
for (int i=9; i>=0; i--){
System.out.println("Hit the Enter key to Start timer");
keyboard.readLine();
timer.start();
System.out.println("Hit the Enter key to Stop timer");
keyboard.readLine();
timer.showElapsedTime();
countDown.decrease();
System.out.print(countDown.getValue());
System.out.println(" More Tries");
System.out.println();
System.out.println("Hit the Enter key to initialize timer");
keyboard.readLine();
}
System.out.println("Due to planned obsolescence, this Stopwatch is no longer operational");
System.out.println();
}
}
class Counter {
public void decrease() {
callCount --;
}public int getValue() {
return callCount;
}
private int callCount = 10;
}