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.