Quick Index

Objectives



Steps



Problem Statement


Concept


A pair is a general purpose class that models a "pair" (i.e. a set of two).

One particular case is when you need to return two objects from a method.

Pair is a simple modeling object type:

Pair
	first
	second

The instance variables (ivars) are "first" and "second".

Coding requirements:







































































































Hints


You only need two ivars, one constructor, and four instance methods for the Pair class





































































































Solution


Here is code with explanations





































































































Test Code


Testing Problem Statement


Also reference the Association test write-up as needed.

Write code to test the model. If you get stumped, look at test code solution.

Test Code Solution


First, try to write test code yourself. Then review and compare the following for possible ideas.


Here is support code that is needed for the test code.

Note that this support code is just one example of a minimal testing framework. Feel free to build your own.