I'm trying to model my business in Java so I can run simulations and find optimal inputs etc. The concept I'm struggling with is how to model an objects state over time. For example imagine we have a class called Farm, it has some variables which remain constant such as area & location etc. But over that Farm's lifetime we will have different lengths of grass, sometimes we will cut the grass for hay etc. There are also different types of grass we can put in which will grow at different rates at different times of year etc. My question is how to create a class for this. If I wanted to get the grass height on date x and compare it to the grass height on date y, how would you set up your class to do so? Are there any patterns related to this implementation?
My initial thought was to create another class Timeline which would essentially hold an object for every day in a list then when it comes to run the program, the Farm class works it's way through that list to build it's model. However, it's been very complicated to implement and I feel there is a much better way to go about it.
Aucun commentaire:
Enregistrer un commentaire