//==============================================================================
// 215 Lab 4 Starter Files
// Spring 2006
//
// Breadth-First Search
//
// packstate.cpp


#include "packstate.h"



//==============================================================================
// The sizes of the three types of objects

const int SIZE[] = { 3, 5, 12 };

// The initial counts of the different types of objects
const int NUM[] = { 6, 30, 5 };



//==============================================================================
// constructor

packstate::packstate()
{
	// bag is empty
	space = BAG_SIZE;

	// nothing is packed, everything is left
	for ( int i=0; i<3; i++ )
	{
		packed[i] = 0;
		left[i] = NUM[i];

	} // end for


} // end constructor


//==============================================================================
// copy constructor

packstate::packstate( const packstate& copy_from )
{
	// copy space in bag
	space = copy_from.space;

	// copy packed and left items
	for ( int i=0; i<3; i++ )
	{
		packed[i] = copy_from.packed[i];
		left[i] = copy_from.left[i];

	} // end for

} // end copy constructor



//==============================================================================
// destructor

packstate::~packstate()
{
	
} // end destructor



//==============================================================================
// GetSuccessors
//
// PRE:  This state has been initialized.
// POST: Creates a queue containing the successors of this state, each of which
//       is the addition of one item to the pack; the number of successors is
//       determined by how many item types have any left to add to the pack.
//       Returns the queue.

deque<packstate> packstate::GetSuccessors()
{


} // end GetSuccessors





//==============================================================================
// GetPacked

int packstate::GetPacked( ItemType item )
{
	return packed[item];

} // end GetPacked



//==============================================================================
// GetLeft

int packstate::GetLeft( ItemType item )
{
	return left[item];

} // end GetLeft





//==============================================================================
// IsFull

bool packstate::IsFull()
{
	return ( space == 0 );

} // end IsFull




//==============================================================================
// assignment operator

const packstate& packstate::operator= ( const packstate& source )
{
	// copy space in bag
	space = source.space;

	// copy packed and left items
	for ( int i=0; i<3; i++ )
	{
		packed[i] = source.packed[i];
		left[i] = source.left[i];

	} // end for

	return *this;

} // end assignment operator





//==============================================================================
// Pack
//
// PRE:  state has been initialized
// POST: packs one more item of that item type

void packstate::Pack( ItemType item )
{
	left[item] --;

	packed[item] ++ ;

	space -= SIZE[item];

} // end Pack
