-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTopSpin.h
More file actions
49 lines (43 loc) · 1.16 KB
/
TopSpin.h
File metadata and controls
49 lines (43 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include "CDLL.h"
#include "TopSpinADT.h"
#include <iostream>
class TopSpin : public TopSpinADT {
public:
TopSpin(int size, int spinSize); //constructor creates a new board from a user inputted size
//~TopSpin();
void shiftLeft(); //moves puzzle one space to the left
void shiftRight(); //moves puzzle one space to the right
void spin();
bool isSolved();
void random(unsigned int times);
friend std::ostream& operator<<(std::ostream& output, const TopSpin& ts);
private:
int spinMechSize;
int boardSize;
CDLL<int> newBoard;
};
static std::ostream& operator<< (std::ostream& output, const TopSpin& ts) {
//will print numbers inside spinner mechanism:
for (int i(0); i < ts.spinMechSize * 3; i++) {
output << "-";
}
output << std::endl;
output << " |";
for (int i(0); i < ts.spinMechSize; i++) {
output << " ";
output << ts.newBoard.getData(i + 1);
}
output << " |";
//will print all other numbers
for (int i(ts.spinMechSize); i < ts.boardSize; i++) {
output << " ";
output << ts.newBoard.getData(i + 1);
}
output << std::endl;
for (int i(0); i < ts.spinMechSize * 3; i++) {
output << "-";
}
output << std::endl;
return output;
}