Machine Problem 1, due Feb. 4

Part of the homework for CS:2820, Spring 2019
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Step 1: Log onto the CLAS linux server

Step 2: Get a copy of MP1.java by executing the following shell command:

   [HawkID@fastx?? ~]$ cp ~dwjones/MP1.java MP1.java

(Explanation: The cp shell command means copy. It takes two arguments, the source and destination file names. In this case, the source file name is long because you're copying from a my directory so the file name includes my HawkID and a tilde ~ prefix. The destination file name is short, just MP1.java in whatever is your current directory at the time you make the copy.)

Step 3: Edit your copy of MP1.java so it claims you as an author. The header comment on the entire file should just claim you -- it is for us when we grade it. Please use your name, formatted as it is in the University's records, followed by your section number.

For each class you alter in solving this problem, add a Javadoc @author tag formatted identically to the author comment in the file header.

The official Javadoc web pages say that "multiple @author tags should be listed in chronological order, with the creator listed at the top." You must follow this rule.

It is unethical to delete the record that someone was an author of a piece of code or to claim authorship without acknowledging others you know to be authors. Deletion of authorship claims will be considered to be academic misconduct. Equally, if you edit a file, you should claim authorship of the changes you made. In the case of this class, a properly formed Javadoc @author tag with your name must be added to every class you edit.

When you edit a large pre-existing source file, do not mix styles. Either make your changes match the existing style of that file or laboriously go through the file to change its style to match your style. Note that Oracle publishes extensive style guidelines. You will not be faulted for following them. They are not exactly the same as the style guidelines I use, but we agree on a number of points.

Step 4: Edit the @version tag on any class you alter so that it reports the date on which you made your last change.

Step 5: Several of the calls to Errors.warn() are immediately followed by calls to System.exit(). Add a new method, Errors.fatal() that works exactly like Errors.warn() but that ends with a call to System.exit(). Use this new method everywhere that it is appropriate, and reformat the code as needed to make it more readable. Your changes should not alter any externally observable behaviors of the program.

Step 6: Edit the main program so that, when there are extra arguments, the warning message includes the extra argument as illustrated by this example:

   [HawkID@fastx?? ~]$ java MP1 this that
   MP1: Extra argument that
   MP1: Can't open this

Those are the only changes you should make to the code! Half the point of this exercise is to show that you can make changes to a Java file without breaking it or making unnecessary changes.

Step 7: After each change to your code, make sure you haven't broken anything by compiling your Java program with this command:

   [HawkID@fastx?? ~]$ javac MP1.java

If you made no errors, there will be no error messages. If you made errors, the error messages always indicate the source file name and the line number, as well as a shippet of text. At first, it may be faster to go back to step 2 than to try repairing any damage you made.

Step 8: Test your code with variations on this command:

   [HawkID@fastx?? ~]$ java MP1

For example, explore how the program responds to its arguments.

   [HawkID@fastx?? ~]$ java MP1 MP1.java "is this right?"

Step 9: Check the format of the file with this command:

   [HawkID@fastx?? ~]$ ~dwjones/format MP1.java

This will detect a number of common defects in input files. It produces no output unless it detects over-length lines, trailing spaces, spaces that might be hiding under tabs, unexpected non-printing characters or similar problems. It is particularly useful after moving files from a DOS/Windows environment where the standard text formats differ somewhat from the formats used on Unix/Linux systems.

Step 10: To submit your work, it must be in a file named MP1.java in your current directory on the CLAS Linux system, and you must know your section number. In the following, what you type is shown in bold face. Begin at the linux command-line prompt:

   [HawkID@fastx?? ~]$ submit MP1.java

The system will respond by prompting you (badly) for the course number:

   Course (22C:016 would be c_016): CS2820

The system will respond by listing the places you can submit. Pick the one that corresponds to your section and the machine problem number. Note, section 0A01 is abbreviated a1, and so on.

   Possible submit directories for /group/submit/CS2820 are:

   mp1/a1
   mp1/a2
   mp1/b3
   mp1/b4

   Choice:   mp1/a1

The system will respond with a confirmation that your submission has been accepted (unless you made a mistake), and then it will return to the command-line prompt:

   * File/directory MP1.java has been 
   *  copied to /group/submit/CS2820/mp1/a1/MP1.java.HawkID.
   [HawkID@fastx?? ~]$

The confirmation message saying that the file has been copied tells you that the submission was successful. You may resubmit as many times as you want; each time you resubmit, your previous submission of that file will be deleted. The completed dialogue on your screen will look like this when you are done:

   [HawkID@fastx?? ~]$ submit MP1.java
   Course (22C:016 would be c_016): CS2820
   Possible submit directories for /group/submit/CS2820 are:
   
   mp1/a1
   mp1/a2
   mp1/b3
   mp1/b4

   Choice:   mp1/a1
   * File/directory mp1.java has been 
   *  copied to /group/submit/CS2820/mp1/a1/MP1.java.HawkID.
   [HawkID@fastx?? ~]$

The output saying "File ... has been copied ..." is your confirmation of successful submission. In the event of insurmountable trouble, do not delete or edit files you have submitted. It is safe to make copies if you want to keep playing with them. Keep the original on the CLAS Linux system until your graded work is returned. This way, the time stamp marking the time of last edit is a trustworthy indicator of whether you did the work on time.

Historically, students unable to successfully complete MP1 for this course have an extraordinarily low chance of success in the course. If this assignment proves daunting, seek help early.