CSC112 Spring 2016 Examples
#include <iostream>1#include <iomanip>2#include "termmanip.h"3#include "rectangle.h"45using namespace std;678void9rectangle::draw() { //draw the rectangle10if(height == 0 || width == 0) return; //skip empty rectangles1112//draw the top and bottom13cout << cursorPosition(tx, ty)14<< setw(width) << setfill('#') << '#';15cout << cursorPosition(tx, ty+height-1)16<< setw(width) << setfill('#') << '#';1718cout << setfill(' ');1920//draw the sides21for(int i=0; i<height-2; i++) {22cout << cursorPosition(tx, ty+i+1) << '#' << setw(width-1) << '#';23}2425cout.flush(); //push to the screen26}2728void29rectangle::getUserParameters(int firstLine) {30//get our parts from the user31cout << cursorPosition(1, firstLine) << "X: ";32cin >> tx;33cout << cursorPosition(21, firstLine) << "Y: ";34cin >> ty;35cout << cursorPosition(1, firstLine+1) << "Width: ";36cin >> width;37cout << cursorPosition(21, firstLine+1) << "Height: ";38cin >> height;39}404142