
#import <objc/Object.h>
#import "ListNode.h"

@implementation ListNode : Object

+ create: (char *)datum
{
   ListNode *n = [[self alloc] init];
   n->data = datum;
   return n;
}

- append: (char *)datum
{
   ListNode *n = self;
   while ( [n hasNext] )
   {
      n = [n getNext];
   }
   return [n setNext: [ListNode create: datum]];
}

- (int) hasNext
{
   return ( next != 0 );
}

- setNext: (ListNode *)nextNode
{
   if ( nextNode == NULL ) return self;

   next = nextNode;
   return nextNode;
}

- getNext
{
   return next;
}

- (char *)getData
{
   return data;
}

@end
