/* ENGR3891 Assignment 6 -- Test Code -- Author: Sheldon Andrews Date: October 30, 2000 */ #include #include "assign6.h" //using namespace std; const int gridWidth = 11; const int gridHeight = 11; char grid[gridWidth][gridHeight]; int main () { Vector myVector (1.00, 1.00); point myPoint; bool loop = true; flip fl = NONE; char *flips[BOTH + 1] = { "NONE", "HORIZONTAL", "VERTICAL", "BOTH" }; while (loop) { myPoint = myVector.get (); cout << "current vector = (" << myPoint.x << "," << myPoint. y << ")" << endl; for (int i = (gridHeight - 1); i >= 0; i--) { for (int j = 0; j < gridWidth; j++) { grid[i][j] = ' '; if (i == (gridHeight / 2)) grid[i][j] = '-'; if (j == (gridWidth / 2)) grid[i][j] = '|'; if (j == (gridWidth / 2) && i == (gridHeight / 2)) grid[i][j] = '+'; if ((j - (gridWidth / 2)) == (int) myPoint.x && (i - (gridHeight / 2)) == (int) myPoint.y) grid[i][j] = '*'; cout << grid[i][j]; } cout << endl; } cout << endl; int menuChoice = 6; cout << "1. Change the flip option (current = " << flips[fl] << ") " << endl; cout << "2. Scale the vector " << endl; cout << "3. Rotate the vector " << endl; cout << "4. Reflect the vector (using above flip option) " << endl; cout << "5. Add a vector to the current vector " << endl; cout << "6. Redraw graph" << endl; cout << "7. Exit " << endl; cout << "Enter your choice -> "; cin >> menuChoice; cout << endl; switch (menuChoice) { case 1: int tempFlip; cout << "NONE = " << (const int) NONE << endl; cout << "HORIZONTAL = " << (const int) HORIZONTAL << endl; cout << "VERTICAL = " << (const int) VERTICAL << endl; cout << "BOTH = " << (const int) BOTH << endl; cin >> tempFlip; fl = (flip) tempFlip; break; case 2: double myScale; cout << "Please enter scale value (eg. 1.50) -> "; cin >> myScale; myVector.scale (myScale); break; case 3: double myAngle; cout << "Please enter rotation angle (in degrees) -> "; cin >> myAngle; //myAngle = (myAngle * (3.14159265359 / 180.00)); myVector.rot (myAngle); break; case 4: myVector.reflect (fl); break; case 5: double addX, addY; cout << "Please enter x and y values for addition vector -> "; cin >> addX >> addY; { Vector tempVector (addX, addY); myVector.add (tempVector); } break; case 6: break; case 7: loop = false; break; default: break; } // switch cout << endl; } // while-loop return 0; }