Quick Index

Objectives



Steps



Also see as needed Generics-Just-Variables

Problem Statement


Concept


Association is a wonderful utility helper class that is useful when coding data structures.

Association is a simple key-value object:

Association
	key
	value

The instance variables (ivar) are "key" and "value".

Coding requirements:







































































































Hints







































































































Solution


Here is code with explanations





































































































Test Code


Testing Problem Statement


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.

Prepare Project



Directory and Files Listing


assoc\model\Association.java
assoc\test\AssociationSmokeTest.java
assoc\test\AssociationTest.java
testutil\AbstractTest.java
testutil\Employee.java

Compile


Here are the console commands to compile all project files (you may also use your favorite IDE):

javac -cp "." assoc/model/*.java
javac -cp "." assoc/test/*.java
javac -cp "." testutil/*.java

Run Tests


Here are the console command to run the tests (you may also use your favorite IDE):

java -cp "." assoc/test/AssociationTest