Results 1 to 4 of 4

Thread: Time constraints on object state

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    2

    Time constraints on object state

    I'm working on a project and I've come across a new thing I'm really new at. I've checked forums, but basicly, I don't know what to look for. I’ll try to explain it as simple as possible and give you an example of what we have to implement.

    The project consists of builing a platform for a company to administrate contracts, transport requests etc. Each contract has, amongst other attributes like “contract period”, a ContractState, using the state pattern. States could be PROPOSED, SIGNED, EXPIRED, etc. We’re not using any kind of database for this, all contract objects are stored in a simple ArrayList.

    So an example of what we’re trying to achieve is that when the time hits ‘creationdate + contract period’ for any contract, that contract’s state automatically changes to EXPIRED. On top of that, we have to be able to jump forwards and backwards in time during execution, for demonstration purposes. We’re thinking about making a clock, relative to the real time by adding or deducting a set period and maybe using an Observer pattern.

    What is the best way to implement this?

    Any tips could be of great help,
    Thanks in advance.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Time constraints on object state

    Here is one way to do it:
    A TimerTask that iterates over your array-list. Or anything that uses threading
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    2

    Re: Time constraints on object state

    That's actually a nice idea, I'll have to check in on it because i haven't used multithreading before but thanks mate.

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Time constraints on object state

    There are lots of threading tutorials online, I'd start with Sun's tutorial. it covers the basics
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

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



Click Here to Expand Forum to Full Width