Description
You will write a black-box test program for the FListDouble ADT as specified below. Collaboration between students is forbidden on this assignment. You are responsible for keeping your code hidden from all other students. Turn in your work on this assignment before 11:59 pm on the due date by following instructions on the course’s main assignments web page, http://www.ccs.neu.edu/course/cs3500sp13/Assignments.html. (The submission command for Assignment 2 will be posted after the late submission deadline for Assignment 1.)
Your file of Java code should begin with a block comment that lists
1. Your name, as you want the instructor to write it.
2. Your email address.
3. Any remarks that you wish to make to the instructor.
Part of your grade will depend on the quality and correctness of your code and black-box tests, part will depend on the readability of your code (comments and indentation), and part will depend on how well you follow the procedure above for submitting your work. Assignments submitted between 12:00 am and 11:59 pm the day after the due date will receive a 20 percentage point penalty on the assignment.
—————————————————————————————————————————
Your assignment is to write the code for a single file, TestFListDouble.java, that implements a
public static void main(String[])
method that, when called with any array of strings, performs black-box testing of any and all implementations of the FListDouble ADT that satisfy its specification given below.
(Note: Your main method should probably just ignore the array of strings that it receives as an argument, since you cannot rely on the number of strings or their content.)
A future assignment will require you to work with other students as a team, implementing a black-box test program and using that program to test implementations of the FListDouble ADT that were written by other students.
—————————————————————————————————————————
Specification of the FListDouble ADT.
FListDouble is an immutable abstract data type whose values represent homogeneous linear lists of Doubles.
The FListDouble ADT shall be implemented in Java and will be tested on CCIS Linux machines with only their standard software. The code for this implementation shall be in the default package and shall define a public class named FListDouble. The operations of the FListDouble class shall be provided by the following public methods of of the FListDouble class:
Signature:
Static methods:
emptyList() : -> FListDouble
add : FListDouble x Double -> FListDouble
isEmpty : FListDouble -> boolean
get : FListDouble x int -> Double
set : FListDouble x int x Double -> FListDouble
size : FListDouble -> int
contains : FListDouble x Double -> boolean
Dynamic methods (for which the receiver is an FListDouble):
toString : -> String
equals : Object -> boolean
hashCode : -> int
Algebraic specification:
FListDouble.isEmpty (FListDouble.emptyList()) = true
FListDouble.isEmpty (FListDouble.add (f, x)) = false
FListDouble.get (FListDouble.add (f, x), n) = x
if n == 0
FListDouble.get (FListDouble.add (f, x), n)
= FListDouble.get (f, n – 1)
if n > 0
FListDouble.set (FListDouble.add (f, x), n, y)
= FListDouble.add (f, y)
if n == 0
FListDouble.set (FListDouble.add (f, x), n, y)
= FListDouble.add (FListDouble.set (f, n – 1, y), x)
if n > 0
FListDouble.size (FListDouble.emptyList()) = 0
FListDouble.size (FListDouble.add (f, x))
= 1 + FListDouble.size (f)
FListDouble.contains (FListDouble.emptyList(), y) = false
FListDouble.contains (FListDouble.add (f, x), y)
= true if x.equals(y)
FListDouble.contains (FListDouble.add (f, x), y)
= FListDouble.contains (f, y) if ! (x.equals(y))
FListDouble.emptyList().toString() = “[]”
FListDouble.add (f, x).toString()
= “[” + x.toString() + “]” if FListDouble.isEmpty (f)
FListDouble.add(f, x).toString()
= “[” + x.toString() + “, ”
+ f.toString().substring(1, f.toString().length())
if ! (FListDouble.isEmpty (f))
Values of the FListDouble ADT shall also implement the public dynamic methods equals(Object) and hashCode() such that
If f1 is a value of the FListDouble ADT, but x is not, then
f1.equals(x) returns false.
If f1 and f2 are values of the FListDouble ADT, then
f1.equals(f2) if and only if:
(f1.isEmpty() && f2.isEmpty())
or (FListDouble.size (f1) == FListDouble.size (f2))
and
for every integer i such that 0 <= i < FListDouble.size(f1) FListDouble.get(f1, i).equals(FListDouble.get(f2, i)) If f1 and f2 are values of the FListDouble ADT, and f1.equals(f2) then f1.hashCode() == f2.hashCode(). If f1 and f2 are values of the FListDouble ADT, and !(f1.equals(f2)) then f1.hashCode() is unlikely to be equal to f2.hashCode().