#include "number.h" #include "ansi.h" #include using namespace std; static const char nums[10][5][6] = { { "#####", "# #", "# #", "# #", "#####" }, { " # ", " # ", " # ", " # ", " # "}, { "#####", " #", "#####", "# ", "#####"}, { "#####", " #", "#####", " #", "#####"}, { "# #", "# #", "#####", " #", " #" }, { "#####", "# ", "#####", " #", "#####"}, { "#####", "# ", "#####", "# #", "#####"}, { "#####", " #", " #", " #", " #"}, { "#####", "# #", "#####", "# #", "#####"}, { "#####", "# #", "#####", " #", " #"} }; //constructor Number::Number() { //start at 0 n = 0; } //drawing stuff void Number::erase() { cout << normal; for(int i=0; i<5; i++) { cout << cursorPosition(x, y+i) << " "; } cout.flush(); } void Number::draw() { //for every row in the number for(int i=0; i<5; i++) { cout << cursorPosition(x, y+i); //for each character for(int j=0; j<5; j++) { // if character is a # display white block if(nums[n][i][j] == '#') { cout << whiteBackground << ' '; } else { // otherwise, display an empty space cout << normal << ' '; } } } cout.flush(); } void Number::setNumber(int n) { //protect ourselves if(n > 9 || n < 0) return; this->n = n; } void Number::setPosition(int x, int y) { this->x = x; this->y = y; }