Computer Science 210
Data Structures

Fall 2017, Siena College

Lab 0: Setting Up
Due: the start of your next lab session

You will work with a partner for most labs, but for this setup lab, you will need to complete the tasks individually.

GitHub for Source Code Control

If all goes well, we will be using the git distributed version control system for nearly all of our work this semester.

If you are not familiar with the basic idea of version control, this brief video is a good place to start.

In particular, we will be using git repositories hosted on GitHub which are managed by GitHub Classroom.

If you do not already have an account at GitHub, please visit and create one. Please use your college-issued email address when you create your account (or, be sure your college-issued email address is associated with your account if you already have one), since GitHub offers free unlimited private repositories for academic use. Also, a username that incorporates your real name is probably a good idea. Building up a portfolio of GitHub repositories that contain your work is a good way to impress future potential employers, so make it a username you won't be embarrassed to put on a resume.

Trying out GitHub with BlueJ

Before you can do this task, you will need to have the GitHub classroom link (sent by email) to be able to create your repository for this lab's work.

On a lab PC, launch the "Git Bash" program. Once it launches, you should see a prompt that looks like this:


Next, create a directory (that's our grown up computer scientist Unix word for what Microsoft and Apple want you to call a "folder") for your work for this course. If you want to name it "ds", use the command:

mkdir ds

Then change your working directory to that new directory:

cd ds

Now, create your GitHub repository for this lab. To do so, open a browser window at and sign in. In the same browser, visit the link you received in your email. This should bring you do a page where you can "Accept the setup-lab assignment". Do so. If that worked, the next page will have a link to a GitHub URL which is your copy of this lab's repository. Follow it.

You are now on the main page for your repository. You should see a screen that looks like this:

Let's add your name to the file in the repository on GitHub. Click on its name, then in the window that comes up, click on the little pencil icon near the "Raw", "Blame", and "History" buttons to bring up GitHub's simple editor.

You'll be editing in a simple markup language called Markdown (please click here and read about it). Add your name to the file, then scroll down to the bottom and "Commit changes". You can leave the radio buttons above that set to "Commit directly to the master branch." Once you've commited your changes, you should now see the file displayed with your additions.

To get back to the main view of your repository, click on the "<> Code" tab.

Next, click on the green "Clone or Download" and copy the URL that pops up. Go back to your git bash window and type

git clone ...

replacing ... with the URL you copied from the web page.

When prompted, log in with your GitHub credentials. You should then see some messages, and a new directory will be created. Change into that directory with the cd command, then list the contents with ls. You should see three files:,, and package.bluej, which are the same three files that were in the repository on the GitHub site.

Before going further, we have a bit of configuration to do for your git setup in the git bash window. Issue these commands (replacing with your own GitHub username and your email, of course) at the terminal prompt:

git config --global "jcool"
git config --global ""

One of those files is a Java program, so let's bring it up in BlueJ to compile and run it. On the lab PC, navigate to the directory where you cloned the repository and double-click on the "package" icon to launch BlueJ. Once it opens, click on the Hello210 class to open the editor. It's a pretty simple Java program. Run it by right-clicking on the class in the object workbench window and choosing the "void main(String args[])" entry.

If all goes well, you should see the "Hello, CSIS 210 world!" printout in the BlueJ Terminal Window.

Now, make a couple changes to the Java program. Put your name in the comment at the top, and add at least one more println statement to print additional messages.

Recompile and re-run your program to make sure it works.

Next, create a new Java class within the same BlueJ project (use the "New Class..." button on the object workbench window). Name the class ConsoleIO, which will create a file

Practice Program: Write a program that reads at least one String from a keyboard Scanner and uses that String as part of its output. This could be as simple as a program that asks for your name, then prints a message that includes your name, or you can get a bit more creative. (10 points)

You might find the section "A Quick Scanner Review" later in this document to be useful as you work on this practice program.

So you now have two copies of the repository, one on the GitHub server (the "origin" repository) and one in your account on your lab PC (a "clone"). Later in the semester, you might have multiple clones in various places (maybe your own computer, or in your lab partner's account) and will want to be able to keep them in sync. Your clone has changes (1 new file, and one modified file) that are not in the origin on GitHub.

git knows what's changed, so let's ask it, in the git bash window:

git status

You should see something like this:

On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)


Untracked files:
  (use "git add <file>..." to include in what will be committed)


no changes added to commit (use "git add" and/or "git commit -a")

This means there is one file that git "knows about" that has changed:, and there are five files that git doesn't know about listed under the "Untracked files" header.

Since the two .class files are compiled versions of your Java classes that gets generated from the Java files, we don't want to store those in our repository. And the .ctxt files are also generated by BlueJ, We'll ignore those for now. But the file is one we want to put in the repository (only because it's part of the grading). We can tell git to start tracking it with

git add

You might get a (hopefully harmless) warning here about line feeds. You can ignore it.

If you rerun the git status command, it should now be listed as a new file.

Once we're happy with a change or set of changes to files in our repository, we need to commit those changes to the repository. In this case, we will issue a command for each file, with an appropriate message in each:

git commit -m "Added name and extra printout."
git commit -m "Practice program."

Now a git status command should show something like this:

On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)
Untracked files:
  (use "git add <file>..." to include in what will be committed)


nothing added to commit but untracked files present (use "git add" to track)

Your changes have been committed to the clone, but they are not yet back up on the origin repository on GitHub. To do that, you will use

git push

This is short for "git push origin master", which says push the changes from this repository to the origin on the master branch. So far, we have not created any branches, so everything is on the master.

If your push command is successful, you should now see your changes reflected on GitHub (in the web page).

One last step: let's make a change right in the GitHub repository and then pull it down to our clone on the PC. Edit the file again to include a bulleted list of the git commands you used in this lab. Use Markdown to make it look pretty. When you are done, include a meaningful commit message and use the green button to commit your changes.

Now the repository on GitHub has changes that aren't in your clone. Back in git bash, we want to "pull down" the changes:

git pull

Now, your on the lab PC should include the changes you made on GitHub.


Your submission requires that all required deliverables are committed and pushed to the master for your repository's origin on GitHub. That's it! If you see everything you intend to submit when you visit your repository's page on GitHub, you're set.


This assignment is worth 20 points, which are distributed as follows:

> FeatureValueScore
GitHub account/accept assignment 2 has name 2 changes 3 correctness 10 has command list 3
Total 20

A Quick Scanner Review

This section is provided for reference for those who might not be familiar with or do not remember the use of Java's Scanner class. There are no additional lab tasks in this section. As you complete the ConsoleIO practice program, you'll want to remember the following: