CSC112 Spring 2016 Examples
// This is a class which implements those notorious little golf-tee puzzles1// found at certain country-themed restaraunts.2// Revision: $Revision: 1.1 $3// Change Log4// $Log: trianglePuzzle.h,v $5// Revision 1.1 2016/03/17 16:01:01 pngwen6// Initial revision7//89#ifndef TRIANGLEPUZZLE_H10#define TRIANGLEPUZZLE_H11#include <vector>12#include "widget.h"13#include "peg.h"1415class TrianglePuzzle : public Widget16{17public:18//Construct a triangle puzzle with a x, y coordinate for the upper19//left hand corner. (As laid out on a 9x27 grid)20TrianglePuzzle(int _x, int _y);2122//Construct a triangle puzzle in the center of the screen23TrianglePuzzle();2425//Volguus Zildrohar the traveler has come!26~TrianglePuzzle();2728//display the puzzle29virtual void display();3031//select a given peg32virtual void selectPeg(int px, int py);3334//move the selection up a row35virtual void up();3637//move the selection down a row38virtual void down();3940//move the selection right a column41virtual void right();4243//move the selection left a column44virtual void left();4546//perform a part of a move. Returns true if valid, false if invalid47virtual bool move();4849//reset the puzzle back to its starting state50virtual void reset();5152private:53std::vector<std::vector<Peg *> > pegs; //the pegs in the puzzle (of course)54int cx, cy; //cursor position55int mx, my; //position of the selected peg for the move56};5758#endif596061