Guest User

Untitled

a guest
Feb 25th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public class Score {
  2.  
  3. private int total;
  4. Time time;
  5.  
  6. public Score(Time time){
  7. this.time=time;
  8. }
  9.  
  10. public int getTotal() {
  11. total=time.getSecondsPassed();
  12. return total;
  13. }
  14.  
  15. public class Time extends Timer{
  16.  
  17. private int secondsPassed = 0;
  18.  
  19. Timer time = new Timer();
  20. TimerTask task = new TimerTask(){
  21. public void run(){
  22. secondsPassed++;
  23. System.out.println("Seconds passed: "+secondsPassed);
  24. }
  25. };
  26.  
  27. public void start() {
  28. time.scheduleAtFixedRate(task,0,1000);
  29. }
  30.  
  31. public void stop() {
  32. time.cancel();
  33. }
  34.  
  35. public int getSecondsPassed() {
  36. return secondsPassed;
  37. }
Add Comment
Please, Sign In to add comment