#include <iostream>
#include "termmanip.h"
#include "peg.h"
using namespace std;
Peg::Peg(int _x, int _y) : Widget(_x, _y, 3, 1)
{
_selected = _occupied = false;
_color = normal;
}
Peg::Peg() : Peg(1,1)
{
}
void
Peg::display()
{
cout << cursorPosition(_x, _y);
cout << "(";
cout << color();
if(isSelected()) {
cout << reverseVideo;
}
if(isOccupied()) {
cout << "*";
} else {
cout << " ";
}
cout << normal;
cout << ")";
cout.flush();
}
void
Peg::select()
{
_selected = true;
display();
}
void
Peg::deselect()
{
_selected = false;
display();
}
void
Peg::place()
{
_occupied = true;
display();
}
void
Peg::take()
{
_occupied = false;
display();
}
bool
Peg::isSelected()
{
return _selected;
}
bool
Peg::isOccupied()
{
return _occupied;
}
colorType
Peg::color()
{
return _color;
}
void
Peg::color(colorType c)
{
_color = c;
}