Solutions
Part of
the homework for CS:2820, Spring 2016
|
a) How many source files do you get when you unpack this shell archive by following the directions given at the head of the text? (The easiest way to do this problem is to simply follow the instructions and then count the number of files you get, but you could also read through the archive and count them in their archived form.) (0.5 points)
Here's what I got when I followed the instructions:
[dwjones@serv16]$ mkdir mp5 [dwjones@serv16]$ cd mp5 [dwjones@serv16 mp5]$ sh < ../mp5shar.txt [dwjones@serv16 mp5]$ ls Errors.java NeuronNetwork.java ScanSupport.java Simulator.java Neuron.java PrimarySynapse.java SecondarySynapse.java Synapse.java [dwjones@serv16 mp5]$
So, the answer is 8
b) If you look at the Javadoc comments in the the new code and compare them to the Javadoc comments in the solution distributed to MP4, you'll see that the volume of commentary has been significantly enlarged. Why is this appropriate? (0.5 points)
With all the classes separated into different source files, connections between classes that were documented by the way they were grouped in a single source file are no longer there, so the connections must be made by comments.
The new class has the following methods:
Note: The header-print method need not have a parameter, since it is always scheduled at time zero. Also, if you add some state variables, for example, a variable indicating that the header is already printed, you could make the print output routine print the header the very first time it is triggered.
A problem: Give a version of Errors.java that meets this standard. (1.0 points)
/** Error reporting methods. * @author: Douglas W. Jones * @author: Andy W.M. Arthur * @version: April 19, 2016 * * This code is extracted from the April 6, 2016 version of NeuronNetwork.java, * which, in turn was based on the non-alternative solution to MP3, * as well as a simulation framework from the March 11 lecture notes. * Better Javadoc comments were added April 19. */ class Errors { /** Count of the number of errors reported so far. * This is incremented by calls to methods of class {@code Errors} * and my be inspected to see if and how many errors have been * reported. */ public static int errCount = 0; /** Called to report a fatal error * @param message the text of the error message * @return void does not return * Reports the error to the {@link System.err} stream and then * terminates the application. */ public static void fatal( String message ) { errCount++; System.err.println( "Fatal error: " + message ); System.exit( 1 ); } /** Called to warn of a non-fatal error * @param message the text of the error message * @return void * Reports the error to the {@link System.err} stream and then * returns, allowing continued processing. */ public static void warning( String message ) { errCount++; System.err.println( "Error: " + message ); } }