1 package DEOS; 20 21 24 class Budget { 25 private int itsTotalBudget; 26 private int itsRemainingBudget; 27 28 public void setRemainingBudgetInUsec (int b) { 29 itsRemainingBudget = b; 31 } 32 33 public void setTotalBudgetInUsec (int b) { 34 itsTotalBudget = b; 35 } 36 37 public void adjustRemainingTime (int b) { 38 itsRemainingBudget += b; 39 } 40 41 public int remainingBudgetInUsec () { 42 return itsRemainingBudget; 43 } 44 45 public void replenish () { 46 itsRemainingBudget = itsTotalBudget; 48 } 49 50 public void replenishAndStartTimer () { 51 itsRemainingBudget = itsTotalBudget; 52 startTimer(); 53 } 54 55 public void startTimer () { 56 DEOS.systemClock.setTimer(itsRemainingBudget); 60 } 61 62 public int totalBudgetInUsec () { 63 return itsTotalBudget; 64 } 65 66 int stopTimer () { 67 itsRemainingBudget = DEOS.theTimer.getRemainingTime( 70 DEOS.systemClock.getCurrentTime()); 71 72 return itsRemainingBudget; 73 } 74 }; 75 | Popular Tags |