1 package DEOS; 20 21 import gov.nasa.jpf.jvm.Verify; 22 23 import java.lang.*; 24 25 26 29 public class NewTimer extends AbstractClockingDevice { 30 int startingTime = 0; int setTime = 0; int stoppingTime = 0; boolean isStarted = false; 34 boolean timeOut = false; 35 boolean isInterrupted = false; 36 37 40 public NewTimer () { 41 } 42 43 48 public int getRemainingTime (int currentTime) { 49 int remainingTime = stoppingTime - currentTime; 51 52 return remainingTime; 57 } 58 59 62 public int getSetTime () { 63 return setTime; 64 } 65 66 70 public int getStoppingTime () { 71 return stoppingTime; 72 } 73 74 79 public boolean isTimeOut () { 80 if (timeOut) { 82 isStarted = false; 83 } 84 85 return timeOut; 86 } 87 88 92 public void setTimer (int setTimeIn, int startingTimeIn) { 93 startingTime = startingTimeIn; 98 setTime = setTimeIn; 99 stoppingTime = startingTime + setTime; 100 101 102 isStarted = true; 104 isInterrupted = false; 105 timeOut = false; 106 107 } 109 110 113 public void clearTimeOut () { 114 timeOut = false; 115 } 116 117 121 public void clockTicks (int currentTime) { 122 if (stoppingTime == currentTime) { 123 timeOut = true; 124 } 125 } 126 127 130 public void interruptTimer () { 131 isStarted = false; 132 isInterrupted = true; 133 } 134 } | Popular Tags |