/******************************************************************************************** Step1.cpp Jim Millard for CO311/Spring 2000 Simple program that displays a 4x4 blue/red checkerboard
Uses the ezwin API ********************************************************************************************/ #include <iostream> #include <string> using namespace std; #include "ezwin.h" #include "rect.h" void DrawCheckerboard(SimpleWindow& W); //required prototype int ApiMain() { //create the primary window SimpleWindow W("Exercise 3.22, Step 1"); W.Open(); DrawCheckerboard(W); //wait for input prior to quitting char ch; cout << "Enter a character to continue"; cin >> ch; Terminate(); return 0; } void DrawCheckerboard(SimpleWindow& W) { const float height=2., //static height of all blocks width =2.; //static width of all blocks float row; //position of the center of the row //Draw the rectangles //first row row = 1.; RectangleShape R11(W,1.,row,Blue,width,height); R11.Draw(); RectangleShape R12(W,3.,row,Red,width,height); R12.Draw(); RectangleShape R13(W,5.,row,Blue,width,height); R13.Draw(); RectangleShape R14(W,7.,row,Red,width,height); R14.Draw(); //second row row += height; RectangleShape R21(W,1.,row,Red,width,height); R21.Draw(); RectangleShape R22(W,3.,row,Blue,width,height); R22.Draw(); RectangleShape R23(W,5.,row,Red,width,height); R23.Draw(); RectangleShape R24(W,7.,row,Blue,width,height); R24.Draw(); //third row row += height; RectangleShape R31(W,1.,row,Blue,width,height); R31.Draw(); RectangleShape R32(W,3.,row,Red,width,height); R32.Draw(); RectangleShape R33(W,5.,row,Blue,width,height); R33.Draw(); RectangleShape R34(W,7.,row,Red,width,height); R34.Draw(); //fourth row row += height; RectangleShape R41(W,1.,row,Red,width,height); R41.Draw(); RectangleShape R42(W,3.,row,Blue,width,height); R42.Draw(); RectangleShape R43(W,5.,row,Red,width,height); R43.Draw(); RectangleShape R44(W,7.,row,Blue,width,height); R44.Draw(); return; } //DrawCheckerboard