//********************************************************************************
// C++ Certificate Program Intermediate Spring 1999 : Stephen Philips
//
// Final Project
// File       : \\Venus\katy\C++ Certificate\intermediate\Final Project\LeafNode.h
//
// Purpose    : Declaration for class LeafNode which is the base class for the
//				Binary tree.
//
// Author     : Hsin-yi F. Berg
// Date		  : 6/1/99
// Update	  : 6/8/99
//********************************************************************************

#ifndef LEAFNODE_H
#define LEAFNODE_H

#include <stddef.h>
#include <assert.h>
#include <iostream.h>
#include <string.h>

typedef char * KEY;

class LeafNode
{
public:
	/*
		LeafNode::LeafNode(KEY word)

		Default constructor for a LeafNode.
		key field of the LeafNode must be provided.
		A LeafNode is not connected to any branch when created.
	*/
	LeafNode(KEY word);

	/*
		LeafNode::~LeafNode()

		Destructor for the LeafNode.
	*/
	~LeafNode();

	/*
		LeafNode *LeafNode::GetLeft(void)

		Get the left pointer of this LeafNode.
	*/
	LeafNode *LeafNode::GetLeft(void);

	/*
		LeafNode *LeafNode::GetRight(void)

		Get the right pointer of this LeafNode.
	*/
	LeafNode *LeafNode::GetRight(void);


	void LeafNode::SetLeft(LeafNode *pLeafNode);

	void LeafNode::SetRight(LeafNode *pLeafNode);


	/*
		void LeafNode::AddLeft(KEY word)

		Set the left pointer of this LeafNode point to a new LeafNode.
	*/
	void LeafNode::AddLeft(KEY word);

	/*
		void LeafNode::AddRight(KEY word)

		Set the right pointer of this LeafNode point to a new LeafNode.
	*/
	void LeafNode::AddRight(KEY word);

	/*
		KEY LeafNode::GetKey(void) const

		Return the key stored in this LeafNode.
	*/
	KEY LeafNode::GetKey(void) const;
 
	/*
		int LeafNode::GetValue(void) const

		Return the value stored in this LeafNode.
	*/
	int LeafNode::GetValue(void) const;

	/*
		void LeafNode::IncrementValue()

		Increment the value of this LeafNode by 1.
	*/
	void LeafNode::IncrementValue();

	/*
		void LeafNode::Print(void) const

		Print the internal data in the LeafNode.
	*/
	void LeafNode::Print(void) const;

private:
	// key is the identifier for this LeafNode.
	KEY key;
	// value is a counter representing how many times the key has been stored.
	int value;
	// pointer points to the left branch of this LeafNode.
	LeafNode *left;
	// pointer points to the right branch of this LeafNode.
	LeafNode *right;
	// maximum number of characters allowed in a word.
	enum {max_char = 128};
};

#endif
Back	Top