lab01 : Tools for java development

num ready? description assigned MW lect due MW lect assigned TR lect due TR lect
lab01 true Tools for java development Wed 01/08 04:00PM Fri 01/17 11:59PM Tue 01/07 04:00PM Fri 01/17 11:59PM

Overview of this lab

If you find typos or problems with the lab instructions, please report them on Slack

  1. You are encouraged to work with a pair partner on this project. Don’t start working unless you are sitting together. This should be a true pair partner assignment. In true pairing, every line of code goes through the minds of two programmers. Please read this blog post from the well-known Agile Coach LLewellen Falco that explains the idea of strong-style pairing.

    • Your pair partner should be someone from your same team, unless that is literally impossible because either
      • Your team has an odd number of people, and everyone is already paired with someone.
      • Your team has an even number of people, but an odd number actually came to section today.
    • If you cannot find someone on your team, check in with the mentor for your team.
    • They will work with the other mentors to try you pair you with someone that is in the same situation
    • If you are literally the last person in your section unpaired, then you may work alone, but you have your mentor send a message on Slack to the #lab01 channel indicating that you got permission to work alone.
    • Make a note of this in your README.md file as well, when you create your GitHub repo for this assignment.
  2. You will need to read through the Rational Tutorial up through exercise 8. This is a series of Java Lessons written by Phill Conrad that walk you through some basics of developing a simple class in Java. Note that even if you are an experienced Java programmer there are likely to be a few things that are new to you. So, at least skim this. A few of the things you might not have encountered in a High School AP Java Course include:
    • The use of Ant and build.xml as a build tool (similar to Makefiles in C++ programming)
    • The use of JUnit for automated testing
  3. Login at github.com.
    Click on the drop down menu at left where your username appears, and ensure that ucsb-cs56-w20 appears
    among your organizations in the drop down menu.
    (Note: The image might have ucsb-cs56-w18, but your page should have ucsb-cs56-w20 instead.

    The URL for that org is https://github.com/ucsb-cs56-w20, and if you followed the steps in lab00, you should have an invitiation to join that org.

    If not:

    • Be sure that you’ve registered for the course at https://ucsb-cs-github-linker.herokuapp.com/. (If that application is not working, ask your mentor to invite you to the organization manually.)
      • MENTORS: If you invite a student to the organization manually, please note this on the instructor Slack channel, including the student’s github_id and umail address.
    • Be sure that you’ve accepted the invitation to the organization ucsb-cs56-w20 by visiting https://github.com/ucsb-cs56-w20
    • If you find that you STILL do NOT have the ucsb-cs56-w20 organization available, consult with your mentor before proceeding.
  4. Repeat the previous step if needed for BOTH pair partners. Each one should verify that they have access to creating repos in the ucsb-cs56-w20 organization. If necessary, allow the pair partner that is not currently logged in to use an “Incognito Window” or the equivalent in your browser.

  5. Now, one of the two of you: create a private repo for lab01 under the organization on
    • It should be called lab01-githubid1-githubid2 where githubid1 and githubid2 are your the githubids of you and your pair partner IN ALPHABETICAL ORDER.
    • (NOTE: yes, hyphens not underscores. Conrad may have showed underscores during lecture, but he goofed.)
    • It should be private, not public.
    • The owner should be the ucsb-cs56-w20 organization as the owner, not your own github id.
    • This time, DO NOT add a .gitignore or README.md file. You want a blank empty repo.

      creating

    • The result should look like this. (Note: Ignore the instructions labelled “… or create a new repository at the command line” that show up on that web page—they’ve been cropped out for a reason. We are going to do something slightly different, so follow the instructions below instead.)

      result

  6. The person that created the repo should add their pair partner as a collaborator on the github repo.
    • You will need their github id in order to do that.
    • The pair partner that was added needs to accept the invitation in order to get the access (see the linked article for details.)
  7. Configure your CSIL account for git
  8. Configure your CSIL account’s ssh keys for git
  9. Review a few basic facts about git, github.com and github.ucsb.edu
    • detailed information here
  10. cd into your ~/cs56 directory on CSIL and create a directory called lab01. cd into that directory and type git init to turn it into a git repository.

  11. We are now going to add TWO remotes to this repo.
    • The following command adds a remote that you can use to get the starter code
      • git remote add starter git@github.com:ucsb-cs56-m18/STARTER_lab01.git
    • The following command adds a remote called origin that refers to the repo on github.com. Instead of the URL below, use the URL for YOUR repo, i.e. substitute your github ids in place of cgaucho01 and ldelplaya99.
      • git remote add origin git@github.com:ucsb-cs56-w20/lab01-cgaucho01-ldelplaya99.git
  12. Now, pull the starter code into your repo with this command

    git pull starter master
    

    This should pull in the starter code for lab01, which is very similar (though not identical) to the code in step 8 of the Rational Tutorial.

  13. Now, do a git push origin master to push this code back to your own private repo.

  14. Now, let’s get your javadoc set up. Try doing ant javadoc at the command line. This should create javadoc in the docs/javadoc subdirectory.

    Do a ls to verify that it got created.

  15. To put in online, go to your repo on github.com, and under Settings for your repo, find the section for Github Pages, and select the master branch and docs folder as shown here:

    docs folder

Visit the url shown there. You may have to add /javadoc at the end of the URL.

Edit the README.md for your repo and put the correct javadoc link into the README.md in place of the one that you see in the placeholder text there. While you are there, read through the README.md that came with the starter code, and make other adjustments as indicated.

  1. You are now ready to work on the programming part of the lab.

    • For that, you’ll need the basic git workflow, explained here

    • Follow the detailed instructions below to complete the programming part of the assignment.

  2. When you are finished, be sure you have

    • done an ant compile, ant test, ant javadoc on the final version.
    • done a git status to see if any changes (e.g. changes to code, build.xml, javadoc) need to be added, committed and pushed)
    • done a final git push origin master to push your changes to github.

    Then submit on Gradescope.

Detailed Instructions for Programming Assignment

method explanation
public static int lcm(int a, int b) returns least common multiple of a and b. See wikipedia discussion
public Rational plus(Rational r) returns sum of this number plus r
public static Rational sum(Rational a, Rational b) returns a+b
public Rational minus(Rational r) returns this number minus r
public static Rational difference(Rational a, Rational b) returns a-b
public Rational reciprocalOf() returns reciprocal (swap numerator and denominator). If numerator if zero, throws an instance of java.lang.ArithmeticException. To review exceptions, see cs56-rational-ex07
public Rational dividedBy(Rational r) returns this number divided by r
public static Rational quotient(Rational a, Rational b) returns a divided by b

Some hints to make things easier:

Suggested test cases:

So, don’t repeat yourself:

IMPORTANT: Edit your README.md

Go back into your README.md file and edit it so that it has the following information.

It is important that you do this so that we can give you proper credit for your work.

If you submitted on Gradescope and you didn’t do these things yet, please submit again.

The reason is that we use these links to determine whether or not you published your Javadoc, which is worth 20 points in the grading rubric. Having those links in the README.md on Gradescope makes it possible for us to check this.

Submitting on Gradescope

NOTE: Before you submit on Gradescope, you must at LEAST have a “stub” for each of the methods that the assignment is expecting. Otherwise, your code will not compile at all.

For this assignment, you should either

  1. Submit on Gradescope directly from your github repo (recommended), OR
  2. submit a .zip file with your entire directory BY DOWNLOADING THAT .zip FILE FROM GITHUB without unzipping it.

We do NOT recommmend zipping the file up yourself; when folks have tried this, the backend of Gradescope tends not to like it. The scripts are set up to look for the .zip format that comes from options (1) and (2) listed above.

Grading