CS 151 - Introduction to Data Structures

Homework 1

Revising Code and Submitting

Read the program design principles and code formatting standards carefully. You are expected to adhere to all stated standards.

This homework has a LOT of very specific instructions. Future homeworks will be much less "do this".
  1. Within VSC, in the "terminal" menu, select "new terminal". This will open a terminal identical to the one you opened in Lab 1.
  2. In the terminal you just opened, make sure you are in the CS151 directory you created in Lab1. If you are not, and you are on a Mac/Unix (or a Windows Powershell) the following will get you there (assuming you did everything above).
        cd ~
        cd CS151
            
  3. Make a new directory for homework 1. One way to do so ... In the terminal window you just opened
        mkdir HW1
            
    You can also create a directory through the VSC GUI (Graphical User Interface).
  4. In the terminal switch directories so that the HW1 directory is where you are at. If you are already in the CS151 directory (and you should be)
        cd HW1
            
    If you are somewhere else, or a simply not sure where you are
        cd ~/CS151/HW1
            
    If you are on a UNIX machine (or a terminal to a UNIX machine), then your command prompt should look like:
        gtstudent@comet:~/CS151/HW1$
    
    where "gtstudent" should be your UNIX login name and "comet" should be the name of the computer to which you are logged in. "~/CS151/HW1" indicates the directory you are currently in with "~" being an abbreviation for your home directory.
  5. Now get some code of mine:
        scp YOURUNIXNAME@web2.cs.brynmawr.edu:/var/www/html/cs151/Data/Hw1/ReadCSV.java ReadCSV.java
    
    Above, substitute you actual UNIX login name for YOURUNIXNAME. You will be prompted for your UNIX password. (When typing your password NOTHING will appear; no dots, nothing.)
  6. In VSC, open the HW1 folder. To do so
    1. File menu / Open .. (not "open folder" or "open workspace")
    2. In the popup, navigate to the HW1 folder and get it highlighted
    3. Click on "open".
    4. It is important that you open folder in which you will actually be working rather than a folder containing that folder. VSC interprets the folder in a folder as having a meaning you do not want.
  7. Create a new Java program file in VSC (within your HW1 folder)
    1. In VSC, switch to the document view by clicking on the overlapping rectangles (upper left corner) -- Note that if you are already in the document view, then tapping on the icon will close the document view. Tap on the icon again to re-open.
    2. Tap on the 'new file' icon to the right of "HW1". Name the file "MyCSVReader.java" (or something equally likely).
    3. If VSC did not do so (often it does), add the standard Java class boilerplate
                          public class MyCSVReader {
                              
                          }
                      
  8. Copy the main method from ReadCSV.java to MyCSVReader.java.
  9. Run your program.
    1. With MyCSVReader.java open
    2. Tap on the insect on the left edge of the screen
    3. Tap on "Run with Java"
    Alternately, just above the main function should be "Run | Debug" in grey text. Click on "Run"
  10. Unless you already fixed the issues, this will not work. Go through you code to find the items underlined with red squiggles. Put your mouse over the underlined text. This will bring up a popup window. Maneuver into the popup and click on "quick fix". The first thing "import ..." in the second popup is usually what you want. (In the case of Iterator, you actually want the second (or at least it was second for me) -- import from java.util) Click on it and the underlining should go away and your program will run. This process often works (but not always).
  11. You will use this CSV reader class in many other homeworks through the semester. So be sure you are comfortable with using this code.
  12. Change following functionality (in the main method of MyCSVReader.java)
  13. Run your MyCSVReader and confirm that you get the same answers.
  14. Further modify you MyCSVReader to read a different data file. Instead of "https://cs.brynmawr.edu/cs151/Data/Hw1/us.csv" have your program read "https://cs.brynmawr.edu/cs151/Data/Hw1/uszipcodes.csv". This file will certainly have some entries of zero length on some lines.
  15. Also change the "maxSplit" value from 4 to 200. (In the same place as you changed the file.)
  16. Create another new Java program file following the directions above. Name is file ReadCSVExtender.java. In this file the Java boilerplate should be
        public class ReadCSVExtender extends ReadCSV {
    
        }
    
    the "extends ReadCSV" is important.
  17. Copy your main method from MyCSVReader to ReadCSVExtender.
  18. Add the following constructor
            public ReadCSVExtender(String name, int maxSplit) throws IOException {
                super(name, maxSplit);
            }    
        
  19. Inside the main method, change any instance of ReadCSV to ReadCSVExtender. (There should be two instances to change)
  20. Run the program as for MyCSVReader. You will probably need to fix the red squiggle problem again.

Make a README

Once you have finished coding make a README file. This file should follow the format of this sample README. This is your opportunity to tell me what went well or poorly, what is still broken and why, etc. I will read, and often respond to, everything you write in the README.

The easiest place to write your readme is within VSC. Make a file just like a standard java file but name it README.txt then just write in it. You should start by copying the sample readme.

Answer the following question (put you answer in the Readme)

Suppose you changed all instances of the string ReadCSV to MyCSVReader in your MyCSVReader.java file. Doing so should result in MyCSVReader neither compiling not running. Why not? Why does the similar change in ReadCSVExtender work?

Submit

If you developed everything on the computers in the lab, you can, or or less, skip down to step 9. If you developed this program on your own computer, do the following to transfer your program to the Linux computers so you will be able to submit.

  1. Open a terminal window on your computer (a windows powershell or a Mac terminal)
  2. Connect to goldengate.cs.brynmawr.edu. To connect:
                      ssh YOURUNIXNAME@goldengate.cs.brynmawr.edu
                
    Enter your Unix password when prompted

    This will, effectively, put you on that computer.

  3. On the linux computer:
                      cd CS151
                      mkdir HW1
                
    You made the CS151 directory in Lab1. You can change HW1 to whatever you like, the directions below assume HW1.
  4. Leave this terminal window open and connected to Linux, you will use it again in a couple of steps
  5. Within VSC open a terminal by going to the Terminal menu and selecting "new terminal"
  6. In the Terminal inside of VSC. Be sure you are in the directory containing your program. Once there, enter
                      scp * YOURNAME@goldengate.cs.brynmawr.edu:cs151/HW1
                
  7. Enter your password when prompted.
  8. You should get messages on screen showing that each file in this directory has been copied.
  9. Confirm that the copy was successful. Back in the Terminal you opened on the Linux machines (in step 2)
                      ls HW1
                
    This should show a list of of the files copied in your scp command.
  10. When all of the files are in the HW1 directory and you are still in the CS151 directory
                      /home/gtowell/bin/submit  -c 151 -p 1 -d HW1
                
    This says to submit for project 1 (-p) everything in the directory HW1 (-d) for the class 151 (-c). You should see listing of all the files you submitted and a message that says "success".
  11. You can submit multiple times. I will grade only the last submission -- unless you tell me otherwise. The submission process attaches a timestamp so I know when you submitted (down to the second). The closest submission I have ever received to the deadline is 7 seconds.

If the submission deadline is approaching and you cannot get this process to work, send email gtowell@brynmawr.edu with all of your files attached. I will accept email submission for assignment 1 ONLY. If you use email to submit, include in your email details of your efforts at using electronic submission and your analysis of why it did not work. (You do not have to be correct, but you have to think.)

Approximate Grading

Usually I will not have this section in assignments

For this assignment, points will be approximately equally allocated among:

Please keep in mind that a program is not complete until it is completely and correctly documented.