Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2370 views
1
// This is a class for implementing peg puzzles.
2
// It displays nifty little pegs. as ( ) and (*) depending on if they are filled
3
// Revision: $Revision: 1.1 $
4
// Change Log
5
// $Log: peg.h,v $
6
// Revision 1.1 2016/03/17 15:54:25 pngwen
7
// Initial revision
8
//
9
10
#ifndef PEG_H
11
#define PEG_H
12
#include <iostream>
13
#include "widget.h"
14
15
typedef std::ostream & (* colorType)(std::ostream &);
16
17
18
class Peg : public Widget
19
{
20
public:
21
//constructors
22
Peg(int _x, int _y);
23
Peg();
24
25
//display the peg
26
virtual void display();
27
28
//select the peg
29
virtual void select();
30
31
//deselect the peg
32
virtual void deselect();
33
34
//fill the peg hole
35
virtual void place();
36
37
//take the peg from the hole
38
virtual void take();
39
40
//get the status of the peg hole
41
virtual bool isSelected();
42
virtual bool isOccupied();
43
44
//get and set the color
45
virtual colorType color();
46
virtual void color(colorType c);
47
48
private:
49
bool _selected;
50
bool _occupied;
51
colorType _color;
52
};
53
54
55
#endif
56
57