|
-
Apr 10th, 2009, 12:32 PM
#1
Thread Starter
New Member
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.
-
Apr 10th, 2009, 07:32 PM
#2
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
-
Apr 11th, 2009, 08:54 AM
#3
Thread Starter
New Member
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.
-
Apr 11th, 2009, 11:26 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|