Due Oct 2 on line
Write version 4 of the epidemic model. This should fix the problem with spaces before commas and semicolons, so the following is now just as legal and has the same meaning as in the code suggested for MP3:
pop 25; house 3.2, 1; // median and scatter of houshold sizes infected 12; employed 0.5; // probability of employment workplace 10.5, 12; // median and scatter of workplace size (syntax error?)
The example community discription that worked for MP3 (with spaces before all the punctuation) should still work.
In addition, eliminate the unrealistic correlation discussed in problem 5 above. The example code distritubed for MP3 created this problem by the way it created new homes and workplaces in parallel. There are several ways to break this correlation, and unfortunately, the changes required to do so are not confined to class Epidemic.
A student asked: Is it OK to just set the delimiter used to divide the input into strings to include not only space, tab and newline, but also comma and semicolon?
Suppose the input looked like this?
house,3.2;,1;;,;,;;,;// median and scatter of houshold sizes
Would your program accept this? The solution distributed to the previous machine problem, and everything discussed in class, required that the comma and semicolon be present. So suppose you get this input:
house 3.2 1 // median and scatter of houshold sizes
Would your program still output an error message complaining about a missing comma and missing semicolon? Also, the previous solution accepts this:
house // household description 3.2, // median 1; // scatter
Would that input still work? The assignment was only to remove the requirement for a space before the punctuation, not to eliminate other things that the previous solution accepted, nor to cease checking for missing punctuation.
A student asked: How do we submit.
Exactly the same submission mechanism as was used for the previous assignment.
A student asked: If we just use two loops, one to create people and link them to their households, and another to link employees to workplaces, does that break the correlation?
No, you have to somehow process the people in a different order in one loop than in the other. Shuffling the list, drawing people at random, or some similar strategy will do this.
A student asked: Can we assume that the scatter is an integer?
No. The math for log-normal distributions makes it clear this is a real number, and in Java, that means a float or a double. Note that the the patterns you use to match floats and doubles are the same.
A student asked: Do we really need to use class MyScanner at all?
No, there is and never was a need for class MyScanner. The only purpose of this class was to hide the ugly details of making scanners deal with the input. This statement applies to data abstrction in general. The fact that no program ever needs to use data abstraction does not mean that data abstraction is bad or that it is a bad idea to use it. This is a class on object-oriented programming. Effective use of data abstraction, classe and objects is a central subject in this class.