Barney is writing a program to store data in a linked list. He is writing the initial program for a maximum of 10 data items.
Each node in the linked list has a data value and a pointer (to the next item).
A null pointer is stored with the value –1
Barney wants the nodes to be stored as objects using object-oriented programming. He designs the following class.
class: node
|
---|
attributes: private
data : Real
private pointer : Integer
|
methods:
new (newData, newPointer)
getData()
getPointer()
setData(newData)
setPointer(newPointer)
|
The constructor assigns the parameters to the attributes to create an object
The class node, uses get methods and set methods.
Describe one difference between get methods and set methods.