MGT 317,HRM 326,GSP 125,CMGT 582,FIN 585,ACCT 505,CIS 517,CIS 517,BUS 661,ECET 365 , ,

UOP GSP 125 Week 2 ILab Rectangles NEW

Check this A + tutorial guideline at

http://www.assignmentclick.com/gsp-125-devry/gsp-125-week-7-ilab-win32game-latest

For more classes visit

http://www.assignmentclick.com/

 

/ lab2: rectangles
// & lt; insert your name here & gt;
// read main.cpp, and follow the instructions at the bottom of main.cpp
#define NOMINMAX // prevent Windows API from conflicting with & quot; min & quot; and & quot; max & quot;
#include & lt; stdio.h & gt; // C-style output. printf (char *, ...), putchar (int)
#include & lt; windows.h & gt; // SetConsoleCursorPosition (HANDLE, COORD)
#include & lt; conio.h & gt; // _getch ()
/ **
* moves the console cursor to the given x / y coordinate
* 0, 0 is the upper-left hand coordinate. Standard consoles are 80x24.
* @param x
* @param y
* /
void moveCursor (intx, inty)
{
COORD c = {x, y};
SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), c);
}
struct Vec2
{
short x, y;
Vec2 (): x (0), y (0) {}
Vec2 (intx, inty): x (x), y (y) {}
void add (Vec2 v)
{
x + = vx;
y + = vy;
}
};
class rect
{
Vec2 min, max;
public:
Rect (int minx, int miny, int maxx, int maxy)
: min (minx, miny), max (maxx, maxy)
{}
Rect () {}
void draw (const char letter) const
{
for (int row = min.y; row <max.y; row ++)
{
for (int col = min.x; col <max.x; col ++)
{
if (row> = 0 & amp; = 0 )
{
moveCursor (col, row);
putchar (letter);
}
}
}
}
bool isOverlapping (Rect const & r) const
{return! (min.x> = r.max.x || max.x <= r.min.x
|| min.y> = r.max.y || max.y <= r.min.y); }; }
void translate (Vec2 const & delta)
{
min.add (delta);
max.add (delta);
} int main ()
{
// initialization
Rect userRect (7, 5, 10, 9);
Rect rect0 (10, 2, 14, 4);
Rect rect1 (1, 6, 5, 15);
int userInput;
do

 

Diskussion