Quick Index
Objectives
Steps
Problem Statement
Hints
Solution
Test Code
Objectives
Java generics
DataNode concepts
Java packages
Writing Test Code
Steps
Take a shot at writing the program after viewing the problem statement
When desired, look at
the hints
When desired, look at
the solution
Problem Statement
Concept
DataNode is a fundamental data structures model type. It is simply a node that holds data (has an instance variable "data").
DataNode is a simple key-value object:
DataNode data
The instance variable (ivar) is "data".
Coding requirements:
Write a class that uses a generic type parameter "T" specified on the class that specifies the value type for ivar "data"
Write a constructor that receives values to set all ivars
Write a
getter
for each ivar
Hints
You only need one ivar, one constructor, and one instance method for the DataNode 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.
Data Node Smoke Test
Data Node
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.
Object Oriented Programming
DataNode
Top
Search
TOC