// Class Declarations for ListOfContracts with the ability to add as many contracts
// as desired
// File: c10lst1a.h  // 

#include "common2.h"
#include "contrct4.h"  // Given a new name just for chapter 9

const CONTRACT_GROWTH = 3;   // Size to start list and to grow by when necessary
							// Use small number for testing purposes

class ListOfContracts
{
public:
	ListOfContracts();
	/*
		Purpose:	to instantiate (create) an instance of the class 'ListOfContracts'.
		Goal:		a new instance of class 'ListOfContracts' now exists

		Receives:	NONE
		RETURNS:	NONE
	*/

	~ListOfContracts(); // the destructor

	void Add(Contract contract);
	/*
		Purpose:	To add an instance of the class 'Contract' to the list.
		Goal:		A new instance of class 'contract' is on the list

		Receives:	a contract
		Returns: NONE:
	*/

   /* This function is complex enough to deserve an algorithm
	Search to find if 'contract' already exists - if need add
	If need add contract  (it is not in list)
		Check to see if there is room on the list
		if no room,
			create more room
		add contract
		increment numContract
	else
		state that it already exists
*/

	void Delete(int contractNum);
	/*
		Purpose:	To delete an instance of the class 'Contract' from the list.
		Goal:		The instance of class 'contract' is deleted

		Receives:	a contract number
		Returns: NONE:
	*/

	bool FindContract(int ID, Contract& contract);
	/*
		Purpose:	To find out if a contract is in the list
		Goal:	If the list holds a contract with id 'ID', the function 
				returns that contract in the variable 'contract' and 
				the function returns true
				Or the function returns false and 'contract' holds garbage.'

		Receives:   A contract ID
		Returns:		Whether or not the contract was found AND if found, the contract
						itself.
	*/

	void ReplaceContract (Contract contract);
	/*
		Purpose:	To replace the properties of one contract in the list
		Goal:    The properties of the contract in the list with the ID of
					'contract' have been replaced

		Receives:	A contract
		Returns:		NONE
	*/

	void DisplayAll();
	/*
		Purpose:	To display all the contracts in the list
		Goal:	All the contracts are displayed

		Receives:	NONE
		Returns:		NONE
	*/


private:
	int numContracts;  // indicates next available slot in list
	int presentMax; // present size of array

	Contract* listOfContracts;
	int Search(int contractID);
	void IncreaseSize();
   /* Another function worth an algorithm
		Increment presentMax by CONTRACT_GROWTH
		Get enough memory for array of new 'presentMax' size and have 'tempArray'
			point to it
		Copy old list contents (listOfContracts) into new list area pointed to by
			tempArray
		Delete memory pointed to by listOfContracts
		Assign pointer value in 'tempArray' to listOfContracts
	*/

};