Homework 1

CS 151 - Introduction to Data Structures

Assignment 1

This assignment will take some of the work that you did in Lab 1, extend that work somewhat, make it adhere to the class style guidelines, and electronically submit it. The class style guidelines are in https://cs.brynmawr.edu/cs151/style.html

Task 1

Do the following:
  1. Make a new directory for this homework. (For instructions on doing so on the UNIX machines, see Lab 1. I assume you can figure it out on your local machine.)
  2. Start VSC.
  3. Open the directory you just made from within VSC. Click on "open ..." in the VSC window, then, in the popup, navigate to the directory you just created and click on the "open" button
  4. Open a terminal (within VSC). Click on the Terminal Menu and select "new terminal".
  5. In the terminal (bottom third of the VSC screen (usually)), enter the following commands
    UNIX lab machine:
    	cp /home/gtowell/Public/151/A01/ReadCSV.java ReadCSV.java
    	cp /home/gtowell/Public/151/A01/us.csv us.csv
    
    On your personal computer:
    	scp YOURUNIXLOGIN@goldengate.cs.brynmawr.edu:/home/gtowell/Public/151/A01/ReadCSV.java ReadCSV.java
    	scp YOURUNIXLOGIN@goldengate.cs.brynmawr.edu:/home/gtowell/Public/151/A01/us.csv us.csv
    
    if you are working on your own computer you will need to enter your UNIX password after each of the scp commands.
    The version of ReadCSV for this homework is different from that of lab 1. It lack the unused echoCSV method and has a new method csvCollectionArray which you will be using.

Task 2

The method ReadCSV.csvCollectionArray() returns an array that contains arrays of Strings. This is very general purpose, the csvCollectionArray method can be used to read pretty much any CSV file, but it is nonetheless awkward and not particularly Object-Oriented to have this as the data format. So, your task is to write a method that takes the array of String arrays (ie a 2-d array of strings) and returns an array containing instances of a class you will write to contain the data in the file "us.csv".

The file us.csv has the following form:

921135,jcbbdf
864364,igedge
431110,edbbba
The first item in each line is an integer (you can use Integer.parseInt("string")) to transform a string into an int. The second item is a string.

Create a class of your own design that has instance variables for holding each of the items on a line. Some requirements of the class:

Finally, create a method within the ReadCSV class that takes the output of csvCollectionArray and returns ar array containing instances of your class. For instance the signature of that method might be

				YOURCLASS[] csvCollectionME(String[][] data)
			

If you write your program on computers other than those in the lab, be aware that your program will be graded based on how it runs on the department’s Linux server, not how it runs on your computer. What this means is that your programs should not use any classes that are not a part of Java 11. For instance, if you took cs113 last semester you might be accustomed to using some classes that are not a part of Java 11. Watch out for those. Similarly, if you have installed Java 14 on you own machine, you might use classes that ae not a part of Java 11. (While neither of these issues are likely to arise. )

The submission should include the following items:

What to Turn in

1. README:
This must be a plain text file called README (or README.txt, or any variation of capitalization). This file should follow the format of this sample README
For this assignment, you can skip the sections on how to compile and how to run.

Probably the easiest way to create the readme file is to make it within Visual Studio Code. Do the same thing you do to create code files, but name the file "README.txt", then write text into it.

2. Source files:
All source files Again, make sure that these files conform to the style guidelines. You should probably have two source files.
3. Data files used:
If you are using standard class datafiles, do NOT include them

If you have done all of your work on a computer not in the CS lab, you will have to transfer everything to CS department computer before you can submit. The following steps should work on a Mac or a Windows 10 PC

  1. Open a command window and ssh to goldengate. That is, withn the command window (mac terminal) enter
    ssh YOURUNIXLOGIN@goldengate.cs.brynmawr.edu
    			
  2. Make a directory named Assignment1 in your cs151 directory. (if you did not create a cs151 directory in lab 1, then you will need to do so now. )
    1. cd
    2. mkdir cs151 (If this directory does not exist)
    3. cd cs151
    4. mkdir Assignment1
  3. Leave the command window open ... you will need it again in a minute
  4. Open VSC and go to the folder in which you did your work. It is probably still open.
  5. In the terminal menu (of VSC), select "new terminal" (within VSC, on windows this opens a powershell, on mac a terminal window
  6. Within the terminal window (within VSC) enter the command
    scp * YOUR_CS_NAME@goldengate.cs.brynmawr.edu:cs151/Assignment1
  7. Return to the terminal that is connected using ssh to goldengate
  8. First, check that the files you intended to copy are actually there:
    ls Assignment1
    . If you copying worked, then you should see all fothe files names from your own computer also on goldengate. Finally, submit your work
    /home/gtowell/bin/submit -c 151 -p 1 -d Assignment1
  9. You must use /home/gtowell/bin/submit Accept no substitute!

For more on using the submit script click here

If you get confused / lost in the submission process see the Lab TAs or me. The TAs can certainly help with any programming questions and should be able to help with the submission process also.