All pastes #253676 Raw Edit

Untitled

public text v1 · immutable
#253676 ·published 2006-11-21 00:00 UTC
rendered paste body
#include <string>
#include <iostream>
#include <sstream>
#include "item.h"
#include "point.h"

int Item::ICount = 0;

// Constructors
Item::Item() {
  ++Item::ICount;
  Serial = Item::ICount;

  std::stringstream ss;
  ss << Item::ICount;
  ss >> Name;

  P = Point(0, 0);
}

Item::Item(std::string& tName) : Name(tName) {
  ++Item::ICount;
  Serial = Item::ICount;

  P = Point(0, 0);
}

Item::Item(std::string& tName, Point& tP) : Name(tName), P(tP){
  ++Item::ICount;
  Serial = Item::ICount;

}

Item::Item(const Item& I) : Name(I.GetName()), P(I.GetPoint()) {
  ++Item::ICount;
  Serial = Item::ICount;
}
  
// Destructor
Item::~Item() { }

// Point Functions
void Item::SetPoint(int x, int y) {
 P = Point(x, y);
}
void Item::SetPoint(Point& tP) { 
P = Point(tP);
}
Point Item::GetPoint() const {
  return P;
}

// Name Functions
void Item::SetName(std::string& tName) {
  Name = tName;
}
std::string Item::GetName() const {
  return Name;
}

// Serial Functions
int Item::GetSerial() {
  return Serial;
}

// Utility Functions
void Item::Report() {
  std::cout << "--Item Report--"
            << std::endl
            << "Name : "
            << Name
            << std::endl
            << "Serial : "
            << Serial
            << std::endl
            << "Point : ("
            << P.X
            << ", "
            << P.Y
            << ")"
            << std::endl
            << std::endl;
}

// Operators
bool Item::operator==(Item& I)
{
	if(I.GetName() == Name && I.GetPoint() == P)
    return true;

	return false;
}