package algorithm;
import javax.activity.InvalidActivityException;
/**
 * Allows to measure the execution time of programs in nanoseconds.
 * @author sonagrigoryan
 *
 */

public class ExecutionTime {
	private long startTime = 0;
	private long stopTime = 0;
	private boolean isStarted = false;
	
	public void start() throws Exception{
		if (isStarted) {
			throw new Exception("The exectution time clock is already started");
		}
		startTime = System.nanoTime();
		isStarted = true;
	}
	
	
	public void stop() throws Exception {
		if (!isStarted) {
			throw new Exception("The exectution time clock has not been started yet");
		}
		stopTime = System.nanoTime();
		isStarted = false;
	}
	
	public long getElapsedTime() {
		return stopTime - startTime;
	}
	
	public void printElapsedTime() throws Exception{
		if (isStarted) {
			throw new Exception("The clock is still running. Stop it first.");
		}
		System.out.println();
		System.out.println(String.format("Execution time = %d nanoseconds.", getElapsedTime()));
	}
	
	
}

@@ -12,16 +12,17 @@
 orithm;%0A
+%0A
 import j
@@ -65,16 +65,38 @@
 on;%0A
+%0A
 /**%0A * 
-A
+Execution time class a
 llow
@@ -187,17 +187,16 @@
 %0A *%0A */%0A
-%0A
 public c

improve comments