CSC112 Spring 2016 Examples
#include "Widget.h"1#include "termmanip.h"2#include <iostream>34using namespace std;56Widget::Widget(int _x, int _y, int _width, int _height)7{8this->_x = _x;9this->_y = _y;10this->_width = _width;11this->_height = _height;12}131415Widget::Widget()16{17this->_x = 0;18this->_y = 0;19this->_width = 0;20this->_height = 0;21}222324void25Widget::clear()26{27//paint over the widget28for(int i=0; i<_height; i++) {29cout << cursorPosition(_x, _y+i);30for(int j=0; j<_width; j++) {31cout << ' ';32}33}3435cout.flush();36}3738int39Widget::x()40{41return _x;42}434445void46Widget::x(int _x)47{48this->_x = _x;49}505152int53Widget::y()54{55return _y;56}575859void60Widget::y(int _y)61{62this->_y = _y;63}646566int67Widget::width()68{69return _width;70}717273void74Widget::width(int _width)75{76this->_width = _width;77}787980int81Widget::height()82{83return _height;84}858687void88Widget::height(int _height)89{90this->_height = _height;91}92939495