Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Score {
- private int total;
- Time time;
- public Score(Time time){
- this.time=time;
- }
- public int getTotal() {
- total=time.getSecondsPassed();
- return total;
- }
- public class Time extends Timer{
- private int secondsPassed = 0;
- Timer time = new Timer();
- TimerTask task = new TimerTask(){
- public void run(){
- secondsPassed++;
- System.out.println("Seconds passed: "+secondsPassed);
- }
- };
- public void start() {
- time.scheduleAtFixedRate(task,0,1000);
- }
- public void stop() {
- time.cancel();
- }
- public int getSecondsPassed() {
- return secondsPassed;
- }
Add Comment
Please, Sign In to add comment