lab01 : Tools for java development
num | ready? | description | assigned | due |
---|---|---|---|---|
lab01 | true | Tools for java development | Thu 01/25 04:00PM | Wed 01/31 11:59PM |
If you find typos or problems with the lab instructions, please report them on Piazza
Overview of this lab
-
Work in your pair partnership on this project. Don’t start working unless you are sitting together. This should be a true pair partner assignment.
-
Login at github.com. Click on the drop down menu at left where your username appears, and ensure that ucsb-cs56-w18 appears among your organizations in the drop down menu.
If not:
- Be sure that you’ve registered for the course at https://ucsb-cs56-w18-signup.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-w18 by visiting https://github.com/ucsb-cs56-w18
- If you find that you STILL do NOT have the ucsb-cs56-w18 organization available, consult with your mentor before proceeding.
- Be sure that you’ve registered for the course at https://ucsb-cs56-w18-signup.herokuapp.com. (If that application is not working, ask your mentor to invite you to the organization manually.)
-
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-w18 organization. If necessary, allow the pair partner that is not currently logged in to use an “Incognito Window” or the equivalent in your browser.
- Now, one of the two of you: create a private repo for lab01 under the ucsb-cs56-w18 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-w18 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.
-
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.)
- 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.)
- Configure your CSIL account for git
- Configure your CSIL account’s ssh keys for git
- Detailed instructions: Configuring your ssh key for Github.com
- At the shell prompt on any of the csil machines, type the following command:
ssh-keygen -f ~/.ssh/known_hosts -R csil.cs.ucsb.edu
- You need to do this because CSIL had new hardware installed over the summer, which caused the host key to change.
- If you get a “no such file or directory” error, then you can skip this step
- Review a few basic facts about git, github.com and github.ucsb.edu
- detailed information here
-
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. - 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-w18/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 ofcgaucho01
and ldelplaya99`.git remote add origin git@github.com:ucsb-cs56-w18/lab01-cgaucho01-ldelplaya99.git
- The following command adds a remote that you can use to get the starter code
-
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.
-
Now, do a
git push origin master
to push this code back to your own private repo. -
Now, let’s get your javadoc set up. Try doing
ant javadoc
at the command line. This should create javadoc in thedocs/javadoc
subdirectory.Do a
ls
to verify that it got created. -
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:
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.
-
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.
-
-
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, you can download a .zip version of your assignment from github, rename it to
lab01.zip
, and submit via submit.cs at this link: https://submit.cs.ucsb.edu/form/project/940/submission- NOTE: When you download the
.zip
file, try to do so in a way that does NOT automatically unzip it as you download it. If you do this, and then “rezip” it before submitting, it can mess up the structure of the file in a way that causes it to fail the tests on submit.cs.
- done an
Detailed Instructions for Programming Assignment
- To the
Rational
class, add both tests and correct implementations of the methods listed below. - Note that for each method, you should add a reasonable number of tests. The exact number is left to you to determine, but it should be no less than three for each method.
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:
- (a - b) is equivalent to (a + (-1 * b))
- (a / b) is equivalent to (a * reciprocal(b))
Suggested test cases:
- What happens when you create the rational with
Rational(6,-3)
orRational(-6,3)
? - What about the rational
Rational(3,-7)
,Rational(-3, 7)
, orRational(-3,-7)
?
So, don’t repeat yourself:
- Multiplication and gcd are already defined for you in the example code.
- You need lcm to find a common denominator to add two rationals, so define lcm before addition.
- The lcm can be defined in terms of gcd and absolute value—see wikipedia discussion. Absolute value is predefined
public int Math.abs(int a)
- Define addition before subtraction, and then define subtraction in terms of addition and multiplication.
- Define reciprocal before division, then define division as multiplication by the reciprocal.
Grading:
- Part of your grade is determined by the points shown on submit.cs
- The remainder is determined by the following:
- (25 pts) Did you follow the instructions for setting up your repo? (naming, making it private, pulling in starter code, adding partner as collaborator)
- (25 pts) Did you publish your javadoc correctly, link to it from your README, and in general, tidy up your README as indicated?