EECS2030E Test 2H

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


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 Test2H.java):

submit 2030 test2H Test2H.java


Other questions

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

Question 1

If a method has a precondition, who is responsible for ensuring that the precondition is met?

A. the client of the method
B. the implementer of the method
C. both the client and implementer of the method
D. neither the client nor the the implementer of the method

Question 2

In a constructor, what two things can the keyword this be used for?



Question 3

State three test cases that you would use to test the implementation of Test2H.sum and explain why you would include these test cases. Make sure that your test cases test different ways that the implementation might fail.




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

submit 2030 test2H answers.txt