Results 1 to 3 of 3
  1. #1
    Jadax is offline Member
    Join Date
    Mar 2011
    Posts
    2
    Rep Power
    0

    Default Creating ticker representing time

    hi guys, the aim here is to create a ticker representing 1 sec in the real world. This is to be used in a game (but the GUI layout etc. not of concern right now). once the command prompt for the game is typed in, the ticker should start and continue counting up until the game is stopped. There are some things that happen at certain ticks (but once again that is not of concern right now).

    Right now I have the following:

    Ticker.java class itself:
    Java Code:
    public class Ticker extends TickerTest {
    public Ticker(Integer 1, Integer 12); //ticks every 1 second and triggers every 12sec
    public void stop();
    public void start();
    }
    TickerTest.java code:
    Java Code:
    public class TickerTest implements Ticker{
      
     private Ticker ticker = null;
            
     public TickerTest() {
     super();
    
    this.ticker = new Ticker(1, 12); //1 tick per sec, triggers every 12 sec 
    ticker.addObserver(this); // add this object as a ticker observer
    }
    
    ticker.start();
    }
    Am I doing it right?

    Cheers

  2. #2
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Smile

    Incorrect code!

    You can implement an interface only. Your class is trying to implement another class.

  3. #3
    Jadax is offline Member
    Join Date
    Mar 2011
    Posts
    2
    Rep Power
    0

    Default

    ok cheers, I changed my code to the following:

    Java Code:
    public class Ticker implements Runnable {
    
    	int time = 0;
    	Ticker()
    	{
    	}
    
    	public void run() {
    		while (time != 100) {
    			System.out.println(time++);
    			try {
    				Thread.sleep(1000);
    			} catch (InterruptedException e) {
    			}
    		}
    	}
    }

Similar Threads

  1. Creating a time sliding window..urgent
    By sm123 in forum New To Java
    Replies: 1
    Last Post: 03-12-2010, 04:12 AM
  2. Representing ERD with symbols
    By vivvy in forum JDBC
    Replies: 1
    Last Post: 02-17-2010, 06:17 PM
  3. Replies: 0
    Last Post: 11-22-2008, 02:49 AM
  4. Java classes representing DB tables
    By aa74 in forum Advanced Java
    Replies: 1
    Last Post: 06-20-2008, 10:06 PM
  5. File creating date/time
    By bugger in forum New To Java
    Replies: 1
    Last Post: 11-11-2007, 08:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •