Assignment 1: Java finger exercises
Due: Wed 01/20 at 11:59pm; self-evaluation due Fri 01/22 at 11:59pm
git clone
1 Purpose
The primary goal of this assignment is to get you writing Java (again or for the first time). As a secondary goal, completing this assignment will help you ensure that you have a properly configured and working Java development environment and IDE, and that you can use the submission system (to be described elsewhere).
2 Getting started
Before you start this assignment, you should make sure that you’ve set up a proper CS 3500 environment. More detailed instructions about how to do this are coming soon, but until then this might help:
We are using the Java SE Development Kit 8 toolchain (JDK 8).
You need a good Java IDE. We recommend IntelliJ IDEA (instructions for licensing it are available on Piazza), but you may use whatever IDE you like.
You will need to install Git if you don’t already have it.
Once you’ve installed JDK 8, Git, and an IDE, you probably need to tell the IDE where to find the JDK and Git. Additionally, you should configure your IDE to set your Java language level to 8—
this is a separate configuration step. We will be taking full advantage of Java 8 in this course. Finally, you also need to configure your IDE with the appropriate style settings: see The style guide below. Go to https://github.ccs.neu.edu/ and make sure you can login with your CCIS username and password. (If you don’t have a CCIS username and password, you must get one.) If you have trouble with this step, you should skip to the second method in the next step (for now).
Get the code for this homework assignment:
The preferred way is to pull from the course’s Git repository. You can use Git directly, or you may be able to use your IDE.
In IntelliJ IDEA, if you don’t have a file open then click Check out from Version Control; if you do have a file open, go to File > New > Project from Version Control. Choose Git (do not select Github), copy and paste
for the Git Repository URL, choose where you’d like your local IDEA project copy to be saved, and clone. (If it asks you whether you want to open the project, say yes.) When it prompts you that Maven projects need to be imported, choose Auto-Import.
If you can’t get Git to work then for now you can download a ZIP archive of the code that you need.
Yes, option 2 looks a lot shorter, but everyone will need to get option 1 working for the next homework in any case.
Take a look at the provided code:
The code from Lecture 2 appears in
src/cs3500/hw01/publication
, with tests intest/cs3500/hw01/publication
.File
test/cs3500/hw01/Hw01TypeChecks.java
contains a small class designed to help you detect when your code may not compile against the grading tests. In particular, if your project cannot compile whileHw01TypeChecks.java
—unmodified!— is a part of it, then it won’t compile for the course staff either.
3 Adding a class
This part of the assignment is a continuation of the code written in
Lecture 2: The essence of objects. In particular, you will write a Java class
Webpage
(in package cs3500.hw01.publication
) that implements
the Publication
interface from lecture, with the same
functionality as web page objects created by the ISL+λ function
new-webpage
, as seen in the lecture notes.
Write a class
Webpage
that implements thePublication
interface. It must define a public constructor:public Webpage(String title, String url, String retrieved)
The signature of the constructor, including the order of the arguments, is important to enable automated-test–based grading for functional correctness. Don’t forget to write a good JavaDoc comment.
Write a JUnit 4 test class,
WebpageTest
, that tests both public methods ofWebpage
.
4 Adding a method
Compared to the version from class this week, there are two changes in the code for this homework:
Interface
Duration
now has an additional method,format(String)
, along with a JavaDoc comment detailing its specification.Class
AbstractDurationTest
contains two simple test methods forformat
, calledformatExample1
andformatExample2
. These serve as examples, and you will need to add several more to have good test coverage.
To complete this assignment, you must:
Implement the
Duration.format(String)
method in the appropriate place(s). Your implementation must not use any of the string replacement methods such asreplace
orreplaceAll
. (Also, while recursion is lovely, we strongly suggest that you not use recursion to process a string.) The Javadoc description of this method is a sufficient specification for this method, but requires careful attention: an overly-hasty reading will probably miss some edge cases.Write sufficient tests to be confident that your implementation of the
format
method is correct. Your tests should exercise every non-trivially distinct possibility.
5 Grading standards
For this assignment, you will be graded on
whether your code compiles,
whether your code implements the specification (functional correctness),
whether you thoroughly test every method that you write, and
how well you follow the style guide.
5.1 The style guide
Coding style is important. For this class we follow Google’s Java style guide. It’s comprehesive but not very long, so I suggest reading the whole thing and then referring to it as needed.
While it can’t yet take on full responsibility for formatting code—
For Intellij IDEA, download
intellij-java-google-style.xml
and save it in theconfig/codestyles/
subdirectory of your IntelliJ configuration folder. Then from within IntelliJ, go to File > Other Settings > Default Settings..., then in the dialog that pops up, go to Editor / Code Style, and select it in the Scheme dropdown, where it should have appeared as an option. If you’ve already created a project, then you’ll additionally need to set this as the project style, using File > Settings.For Eclipse, download the
eclipse-java-google-style.xml
. Under Window > Preferences, select Java / Code Style / Formatter and import the settings.Check here for more info.
6 Submission
6.1 Deliverables
Your submission should include
Webpage.java
,WebpageTest.java
, andany files you had to modify or create in order to implement and test your
format(String)
method.
Do ensure that your code compiles. Half of your grade is for correctness as determined by automated testing, so code that doesn’t compile is subject to a 50% penalty up front.
6.2 Instructions
You will submit your homework at https://cs3500.ccs.neu.edu. Log in with your CCS username and password. If you do not have one, you cannot submit your homework, so obtain one immediately and email the course staff (look on Piazza for more information). Once logged in, you will need to enter some simple profile information (name and nickname, mostly), and upload a picture of yourself so we recognize you. After completing that profile, you’ll be taken to a page like this one:
This screen will show you:
Your profile information
The minimum and maximum possible grades you can still get in this course. These are estimates, and depend upon how many homeworks we ultimately have, exact exam weights, etc. (At the moment, only one homework is created, so the maximum possible grade is a 7.5%.) Your “grade so far” will always be between these two extremes.
The class-wide statistics for the same data, so you can see roughly how your performance compares to the rest of the class.
For each assignment, you can see links to submit the homework files and/or view the files you’ve submitted. You can see the overall weight of the assignment, and your grade for the assignment. If the deadline has not yet passed, you can resubmit your homework as often as you’d like.
Once the homework deadline has passed, the “Self Evaluation” text will become a link to a survey (that you must complete within two days of the homework deadline) asking questions about your submission. The survey will not be available in advance, as it will contain spoilers about what your code should have contained...
In the survey, the first question or two will be auto-graded, and do not require feedback from you. (They will check automated tests and automated style, respectively.) Those results will not be available each time you submit (unlike Fundies 2; they’re only semi-automated...), so don’t panic if your grade remains at 0% for a while.