Stop Watch - Java Pt. 2

Chris Chen
/*
* Pupose: to create a class which interacts with the StopWatch GUI
*/

public class Timer {

private long startTime; //stores the starting time
private long endTime; //stores the ending time

//setter method for the starting time
public void setStartTime(long startTime) {

this.startTime = startTime;

}//end setStartTime

//setter method for the stopping time
public void setEndTime(long endTime) {

this.endTime = endTime;

}//end setEndTime

//returns the difference between the starting time and the ending time
public double getElapsedTime(){

double elapsedTime = (double)((int)((endTime - startTime)/100))/10;
return(elapsedTime);

}//end getElapsedTime

}//end Timer

Published by Chris Chen

Chris is currently attending the University of California, Berkeley seeking an undergraduate's degree in Electrical Engineering Computer Science. He enjoys playing basketball, practicing kendo, hanging out w...  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.