Simple multiple choice questions, 1 point each:
In the epidemic simulator distributed in the posted solution to MP8, we face
a problem when an empolyee dies because there is always a pending event
schedule to wake that employee up the next morning in time for the trip to work.
We need to prevent the employee from being resurrected by this event.
How is that problem detected?
a) Unschedule that event in the be-dead event.
b) Check for infection-state dead on arrival at any place.
c) Unschedule any pending arrival event in the be-dead event.
d) Check for infection-state dead in every event involving a person.
e) Check for infection-state dead in the daily go-to-work event.
In the code for MP8, a simulated person can die in transit only when the
time between becoming ...
a) infectious and dead is shorter than the travel time.
b) bedridden and dead is shorter than the travel time.
c) infectious and bedridden is shorter than the travel time.
d) asymptomatic and dead is shorter than the travel time.
e) asymptomatic and bedridden is shorter than the travel time.
Suppose class Simulator had a method unschedule(e) to
remove e from the pending event set. Using this to prevent
accidental resurrection of the dead would require adding the following
fields to class Person or one of its subclasses:
a) the pending arrival event for any person in transit.
b) the pending go-to-work event for employees only.
c) the pending be-dead event, if any, for any sick person.
d) both a and b.
e) both b and c.
Class Simulator in the posted solution to MP8 would need several
changes in order to allow a previously scheduled event to be unscheduled.
Which of the following would not be appropriate for this:
a) schedule should return the handle for the event it created.
b) eventSet should be made final.
c) class Event would need to be public.
d) unSchedule would need to call eventSet.remove.
e) in Event, time and act should be final and
set by a constructor.
In our new framework, class Event is public. Why does this make
it important to make the time field final?
a) To prevent users from changing event times after they are scheduled.
b) Because users prefer to set the time field using a constructor.
c) So that event times will not spontaneously change.
d) To prevent code outside class Simulation from changing times.
e) Because time is a primitive type, not a full-fledged class.
Machine Problem 10 -- due Monday, Nov 16
Rewrite the code from MP9 to use the new simulation framework demonstrated
in lecture on Nov. 10; here is
that framework, with time units added.
Make sure it still works and make sure the Javadoc comments in the code
you submit look good and do not cause errors.
Note that you will be completely responsible for issues of style, and that
your code will be checked both by javac and by javadoc so
make sure there are no errors flagged by either one of them. Quality of
Javadoc comments is definitely relevant here!
Submit your code for class Person, just that one class,
in the usual way.
A student asked:
If we change the framework, it causes trouble all over the place, not just
in class Person. Does this mean that we have to make changes
Yes, you need to make changes to every call to Simulator.schedule().
You are only turning in your code for Person.java, but you will have
to change many other files to change the simulation framework.
A student asked:
The old Simulator.java defined a bunch of time units like
hour and minute, but the new framework doesn't.
Oops. My error. You can add them to the new Simulator.java,
or use my edited version of the framework with
those changes done.