EECS2030E Test 2G

Tue Oct 4, 2016, 16:00-17:20
LAB 02
Version G


Instructions

There is one programming question and three other questions.

Instructions for submitting your solutions are given in the question sections. You may submit as many times as you want; your most recent submission will be the one recorded.

You may leave the lab when you are finished with the test.


Programming question

Implement this API. You do not have to include javadoc comments.

Here is a main method that you can use to perform some simple testing of your code.

Submit your program using the following command in a terminal (make sure you are in the directory containing your file Test2G.java):

submit 2030 test2G Test2G.java


Other questions

Create a file named answers.txt for your answers to the following questions.

Question 1

What is the definition of a test case?


Question 2

State two test cases for the method Test2G.interval. Try to state test cases that test different ways the method implementation might fail.



Question 3

Suppose that two Student objects are considered equal if their student numbers are equal; in the Student implementation, the student number is stored as a String, and student numbers are guaranteed to not be null nor empty.

The implementation of the Student class looks like:

public class Student {
  private String studentNumber;
  
  // constructor, equals, and other methods not shown but are
  // guaranteed to be correct
  
  public int hashCode() {
    return this.studentNumber.length();
  }
}

Propose a different and better hashCode implementation and explain why your implementation is better than the one shown above.




Submit your program using the following command in a terminal (make sure you are in the directory containing your file answers.txt):

submit 2030 test2G answers.txt