Info

weather, initialize(props);

soil.initialize(props);

plant.initialize(props);

while (weather.hasNext()) { weather. nextQ;

soil.calculateRate(); if (plant.isPostPlantingO) p lant. calculateRateQ;

soil.integrate(); if (plant.isPostPlantingO) plant.integrateQ;

Figure 8-39. Implementation of class SimulationController in Java (part 2 of 3).

Lines 16 through 24 establish the relationships between created objects as required by the conceptual diagram presented in section 4.1 Conceptual Model for the Kraalingen Approach. Lines 26 through 31 define method getlnstanceQ that returns the unique instance of the class. This method implements the lazy initialization principle, which requires instantiating an object only when it is needed. Lines 33 through 56 show the implementation code for method simulate(Propertiesprops). Lines 34 through 37 initialize the three entity objects involved in the simulation process. Note that some of the initial values for populating each of the entity objects are stored in the props file. Each of the objects will read the appropriate data from the props file. Lines 39 through 55 show the iteration over the weather data. At each step of the simulation (i.e., every day), the processes of rate calculation and integration take place. Lines 50 through 54 implement the repetition condition; if plant has not yet reached the status of maturity, then the simulation will continue. The simulation will terminate if the plant reaches the status of maturity and the final results will be stored in the props file.

51 plant. setMaturityDay ();

52 saveFinalResults();

53 return;

57 public Properties getPropertyFile() {

58 return props;

0 0

Post a comment