Lab: Set Implementation on Queue
Objective
In this lab you will practice implementing and testing a kernel
component, Set2 implemented on Queue.
Setup
To get started, import the project for this lab, SetOnQueue, from the
SetOnQueue.zip file available at this link. If you
don't remember how to do this, see the Setup
instructions
in the previous lab.
Method
- Take a look at the
srcandtestfolders in your new project. Open theSet2.javafile in thesrcfolder and explore it. In particular, take a look at the private members (the representation) at the top of the class and the convention and correspondence in the Javadoc comment for the class. Remember that the correspondence clause is a mathematical statement that describes how a client should interpret the variables in the data representation (denoted by$thisfollowed by a dot and the name of the instance variable) as an abstract value of aSetvariable (writtenthis). The convention clause is a mathematical statement that describes properties the implementer claims are satisfied by the data representation at the end of every method call, including the constructor(s); it therefore mentions only the data representation,$this, and not the abstract value as seen by the client,this. (Note that the notation$thisnever appears in Java code, but only in Javadoc comments like this that describe aspects of the data representation!) - Paste the code you wrote for the homework into the body of the
private method
moveToFront, and complete the body of the kernel methods (add,remove,removeAny,contains, andsize) inSet2in thesrcfolder. - Paste the test cases you designed for the homework at the end of the
SetTestclass in thetestfolder. - Run
Set2Testin thetestfolder to test your implementation ofSet2. Fix any bugs that you discover and/or add extra test cases, if you realize that you are missing some important cases.
Additional Activities
- Take a look at the
Standardmethods (newInstance,clear, andtransferFrom) inSet2. We will discuss the details of these implementations later in the semester, but for now, design test cases to test these methods and add the test cases to your test fixture,SetTest.