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
-
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.
- Your pair partner should be someone from your same team, unless that is literally impossible because either
- 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 toMakefile
s in C++ programming) - The use of JUnit for automated testing
- The use of Ant and
-
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.
- 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.)
-
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.
- 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.
-
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
- 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-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 ofcgaucho01
andldelplaya99
.- git remote add origin git@github.com:ucsb-cs56-w20/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 submit on Gradescope.
- 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.
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.
- For both pair partners, add your name and your github id near the top of the file.
- Add a link to the repo itself, e.g. https://github.com/ucsb-cs56-w20/lab01-cgaucho99-ldelplaya32
- Add a link to your published javadoc: e.g. https://ucsb-cs56-w20.github.io/lab01-cgaucho99-ldelplaya32
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.
- EVEN IF it compiles perfectly and runs perfectly on your machine, and/or on CSIL, keep in mind that on Gradescope, the code will be compiled against unit tests for ALL of the methods that the assignment expects.
- YOU CAN get a partial credit grade for partial work IF you write STUBS for all of the methods that compile cleanly. Those stubs can return any answer (even a wrong answer) that is of the correct type. But they must EXIST.
- YOU CANNOT submit on gradescope for partial credit if you haven’t made correct stubs for EACH AND EVERY method in the lab spec. This is going to be true throughout the course.
For this assignment, you should either
- Submit on Gradescope directly from your github repo (recommended), OR
- 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
- (80 pts) of your grade is determined by the automatic points assigned on Gradescope for automated tests.
- The remainder is determined by manual grading using the following rubric:
- (10 pts) Did you follow the instructions for setting up your repo? (naming, making it private, pulling in starter code, adding partner as collaborator)
- (10 pts) Did you publish your javadoc correctly, link to it from your README, and in general, tidy up your README as indicated?