Assignment 1: Java finger exercises
1 Purpose
2 Getting started
3 Representing simple e-books
4 Examplar:   Creating examples to guide implementations
5 Correct the bugs
6 Adding a class
7 Adding a method
8 Grading standards
8.1 The style guide
9 Submission
9.1 Deliverables
9.2 Instructions
8.11

Assignment 1: Java finger exercises

Due dates:

Starter files: code.zip

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.

2 Getting started

Before you start this assignment, please ensure that you have all the necessary tools to complete an assignment. They include:

Please review the directions on the course page if you need help setting up any of this, or talk to the course staff.

3 Representing simple e-books

In this assignment, we’ll think about e-books and some possible data representations for them. For now, we will ignore punctuation marks completely (i.e., will not check for them in arguments, and pretend they don’t exist in examples), and expect only two behaviors:

The starter code contains two classes that implement e-books: a section, and a paragraph. The Javadoc in those classes should explain what they are intended to represent.

4 Examplar: Creating examples to guide implementations

A key task in understanding the meaning of a data definition is creating sufficient examples to illustrate its intended behavior in a representative variety of settings. In the next few assignments, you will be creating and submitting examples without having a working implementation to start from. In this assignment, you have been given starter code that contains mostly working implementations. There are several bugs that have been deliberately left in the starter code.

Your initial task is to write a collection of test methods in the ExamplarEBooks class (in the default package, not in the same package as the EBooks starter code) that demonstrate how these two classes are supposed to work. This means that when you write your examples and run them on the starter code, they should not yet all pass.

For this part of the assignment, you will submit only the ExamplarEBooks.java file:

Regardless of which way you submit the code, do not submit the starter code we give you.

You should not proceed to the next portion of this assignment until you have (nearly) 100% Correctness and Thoroughness score on your Examplar submission. (We obviously cannot prevent you from jumping ahead, but you will get more benefit from this portion of the assignment if you work through it before the remaining pieces.)

Hints for this assignment:

5 Correct the bugs

Once you’ve completed Examplar above, repair the starter code we give you and correct the bugs in it. You should now be able to run your Examplar tests against your own code, and they should all pass.

6 Adding a class

In lecture, we discussed designing an interface for a data defintition to allow us to add new implementations of that interface that made different design tradeoffs. You will repeat this process here for a different data definition.

As we did in class, you will create a new class Hyperlink (in package cs3500.hw01.ebooks) that implements the EBookFlow interface. A hyperlink consists first of a flow of content to show, and second a link destination (which in a “real” e-book reader would be opened in a browser when the person clicked on the link). It must define a public constructor with two arguments as described above.

Write a JUnit 4 test class, EBookTests, that include the new tests you add for this method — keep your existing Examplar tests in the existing ExamplarEBook class.

7 Adding a method

Add a new method to EBook,

String format(int lineWidth);

The intent of this method is to “render” the e-book such that it fits on a screen of the given width (measured in characters), without any horizontal overflow. This method should compute the rendered e-book as a single string as follows:

Your method may need to throw exceptions: if so, they must be documented in your Javadoc for the method.

You may choose to change the implementation of the starter code given to you, if you think the existing represenation is inconvenient for implementing this method. If you do so, leave a comment within the Javadoc of the class, as follows:

/**
 * ... existing Javadoc ...
 * @implNote ...explain what you changed about the representation, and why...
 */

8 Grading standards

For this assignment, you will be graded on

8.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—much less for programming style more broadly—your IDE may be able to help you follow the code formatting portion of the style guide:

9 Submission

Ready to submit? Look at the Design Principles Master List first! (Not all items there may apply to this assignment)

9.1 Deliverables

9.2 Instructions

You will submit the assignment on the Handins server. Follow these instructions:

  1. Log in to the server using the link above, using your Khoury account (not your Northeastern account). Follow directions on the course page if you do not have a Khoury account or have forgotten your password.

  2. You must be registered as a student to CS 3500 for Fall 2023 on the handin server. Follow directions on the course page if you have not applied for registration.

  3. Submit each of the zip files you made above to the relevant assignments (“Hw 1 – Examplar” and “Hw 1”) on the submission server. Note that for the autograded portions, it may take some time to see feedback. This time increases as we get closer to the deadline, because many more students tend to submit. Please be patient!

  4. You have three submissions for this assignment: the Examplar submission, the implementation submission, and the self-eval. Make sure to submit to each of them by their respective deadlines.