Details of this Paper

Lab 6 new




Requirements;Extend the epidemic among pigs simulation so that it either reads its configuration from a file, or logs its reports to a file, or both.;Do not rely on Unix I/O redirection to access the files, you must open the files within Java.;Configuration File;The configuration consists of those parameters or settings that affect how the simulation runs, we?ll call them ?configuration variables.? Your configuration variables should probably include the number of pigs at the start of the simulation, the number or the proportion initially infected, the world dimensions (width and height), when to stop the simulation. Depending on your extra features and so forth, you might have additional configuration variables.;The configuration file should be a plain text file (so you can use a text editor to change it), consisting of one line per configuration variable. The line begins with the configuration variable name (so the data are self-describing), followed by optional punctuation and/or whitespace, followed by the configuration variable value.;For example, it might include lines like this;number of pigs:100;world width: 850;world height: 850;Or, you might prefer something like this;NumberOfPigs 100;WorldWidth 850;WorldHeight 850;The simulation program should read the file when it starts, and use it to set up the intitial conditions of the simulation.;The advantage of a configuration of a file is that you can make changes to the configuration by editing the file, and run the program with the new configuration, without having to recompile the program as you would have to do if you made changes to the source code. So, whatever assumptions in the simulation are likely to change, should go in the configuration file.;Log File;Those reports you have been periodically printing on the console, showing the time (in suitable units) and the number of pigs living, dead, sick, healthy, and immune, should now be written to a log file. (Whether you continue to print them on the console in addition to the log file is your choice.) The log file can then be opened by an external program, such as a spreadsheet or a statistical package, for further analysis of the simulation results.;The format of your log file will depend on the formats accessible to the external program, so, within reason, you can choose. But here are a few suggestions;There should probably be a line of column headings (names of the outputs).;After the headings, each report should be a single line, with values separated by spaces, tabs, or commas. (Comma-separated variables or CSV is a widely supported data interchange format.);Here are a couple of examples of how it might look;hours alive dead sick healthy immune;0 100 0 1 99 0;24100 0 3 97 0;48100 0 7 93 0;72100 0 11 89 0;96100 1 8 91 2;or (CSV);hours,alive,dead,sick,healthy,immune;0,100,0,1,99,0;24,100,0,3,97,0;48,100,0,7,93,0;72,100,0,11,89,0;96,100,1,8,91,2;Hints;Open the file(s) before the simulation starts.;Read the configuration file and close it before the simulation starts.;Write the log file repeatedly as the simulation runs.;Close the log file when the simulation is finished.;Deal reasonably with exceptions. The Java compiler will tell you which exceptions you have to deal with.;What to Turn in;All sections: turn in your work throug Oncourse Assignments.;All Java source files.;Sample input (configuration) file or sample output (log) file or both.;Criteria;Requirements;***IMP***Using one file (configuration input or log output);File is properly opened and closed;File is properly read or written


Paper#67525 | Written in 18-Jul-2015

Price : $43