Assignment 3Due Sep 10 on line
    
     Part of 
      
      the homework for CS:2820, Fall 2020
      
     
       | 
From here on in, each week's work will include two separate components, programming, worth half the credit, and questions, worth the other half. Since we are only giving credit for the top 10 scores, each week's work will be worth 10 points, 5 for questions, 5 for programming.
Write version one of the epidemic model. This should accept input from a text file named by the first command line parameter, where the file has the form:
pop 25 ; house 3 , 1 ;
All it should do is read the numbers (using a scanner) and create the required number of people (25 for the example input above), then assign them to households so that the household size is uniformly distributed over the range given by the average and variation (3 plus or minus 1 for the example above).
Then, print out the entire collection of people, listing, for each person, their name and the household to which they belong, one line per person. A typical line for one person might look like this
person@896001 place@321045
And, print out the entire database of households, listing the name of the household and the names of the people that belong to it, one line per household. A typical line for one place might look like this
place@321045 person@896001 person@301579
The only rule for names is that the name should be textual and it should identify whether it is a person or place name. Every Java class has a default toString method that meets this requirement, although the strings it produces are ugly.
Your code must be in a single source file named Epidemic.java the CLAS Linux system. This implies that the main method is in a class called Epidemic. To submit your solution, use the following Linux shell command:
~dwjones/submit SECTION Epidemic.java
Where SECTION is the section number you are registered in, which must be one of 0A01, 0A02, 0A11 or 0A12.
If it compiles and runs on our test files, we will look at the source code.
A student asked: How do we organize our solutions, as just one source file or multiple files?
A student asked: Do we use class home or class place for the single class that will later be subdivided into subclasses for different kinds of place? Or should we use both?
A student asked: I'm having trouble figuring out how to read the input.
import java.util.Scanner;
import java.io.File;
public class Fool {
    public static void main(String[] args) {
        try {
            final Scanner in = new Scanner( new File( args[0] ) );
            in.next( "pop" );
            int pop = in.nextInt();
            in.next( ";" );
            in.next( "house" );
            int house = in.nextInt();
            in.next( "," );
            int var = in.nextInt();
            in.next( ";" );
            System.out.println( "pop = "+pop+" house = "+house+"+/-"+var );
        } catch ( Exception e ) {
            System.out.println( "oops: "+e );
        }
    }
}
This code is awful. It fails with an ugly exception message and gives no helpful feedback about errors. If the real input gave the right bits in the wrong order, or if someone left out a comma or semicolon, they'd get no help. In the long run, you want your code to be more forgiving. It would be nice if it didn't bomb on missing punctuation, and it would be nice if it allowed the keywords in any order. Perhaps there could be default values for the numbers a person forgets to specify?
A student asked: Is it OK to interactively prompt for input? That is, the program outputs: "Enter population size" and the user types that, etc.?
A student asked: How do we run the program with the expected file? And does it matter what we call the test file.
    javac Epidemic.java
And, assuming it compiles with no errors, you'd run it with this:
    java Epidemic testfile
And it doesn't matter what you call your test file, and you have no reason to know what we call our test files, because the file name is a parameter to your main program. This means you can have as many different test files as you want.
A student asked: I am having difficulty understanding what it means to assign people to homes.
A student asked: How do you create a specific number of Person objects Nothing I’ve looked up shows that dynamically creating a variable amount of objects is possible (even wise) in Java.
A student asked: What about at the end of assigning people to households, when you throw the final random number and it says create a household of 3 people but there is only one person left. Where do you put that person? Add them to an existing but underpopulated household? Create an under-populated household?
For our purposes, though, this kind of underspecification is very typical of real-world problems. If you model a large population, nobody will noticd the difference between the two suggested solutions. Either one will work, so the obvious answer is, do whichever is easier.