#include <iostream>
#include "posizione.h"

Posizione::Posizione ( int _x, int _y ) {
   setX( _x );
   setY( _y );             
}
      
int Posizione::getX ()  {
   return x;
} 

int Posizione::getY ()  {
   return y;
} 

void Posizione::setX (int _x) {
   x = _x;
} 

void Posizione::setY (int _y) {
   y = _y;
}  
 
void Posizione::moveTo( const Direzione & dir) {
   Direzione ddir = dir;
   string d = ddir.getDirezione();
   if ( d == "NORD" ) 
       x--;
   if ( d == "EST" ) 
       y++;
   if ( d == "SUD" ) 
       x++;
   if ( d == "OVEST" ) 
       y--;
}  
 
bool Posizione::operator< ( const Posizione & p) const {
   if (  (x < p.x) || ( (x == p.x) && (y < p.y ) )  )
      return true;
   else
      return false;
}  

bool Posizione::operator== ( const Posizione & p) const {
   if ( (x == p.x) && (y == p.y) )
      return true;
   else
      return false;
}  
   
bool Posizione::operator!= ( const Posizione & p) const {
   return !(*this == p);
}     


void Posizione::stampa () {
   cout << "[" << x << "," << y << "]";
}