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

UOP GSP 125 Week 5 iLab Shapes NEW

 

Check this A + tutorial guideline at

http://www.assignmentclick.com/gsp-125-devry/gsp-125-week-5-ilab-shapes-latest

 

For more classes visit

http://www.assignmentclick.com/


// INSTRUCTIONS
// ------------
// Compile this code. After pressing any key to clear the instructions, you
// should see three rectangles labeled '#', 'b', and 'c'. You should see
// two triangles, labeled 'd' and 'e'. Pressing '>' and '<' wants change which
// shape is labeled '#'. Pressing 'w', 'a', 's', and 'd' will move the shape
// labeled '#'. Pressing 'space' wants to randomize the selected shape.
//
// Read through this code! Try to understand it before starting the assignment.
// Comment confusing lines with what you think is code, and experiment
// with existing code to test your understanding.

// and make sure your code compiles and runs after each step is completed.
//
// 1. Getting
a "makeRandom" method in both the Rect and Tri classes,
// based on the "makeRandomRect" and "makeRandomTri" functions in
// "application.cpp" , The makeRandom function should take no parameters,
// and instead make itself random. Removing the old "makeRandomRect"
// and "makeRandomTri" functions as well. Be sure to consider what to do
// about "screenMin" and "screenMax".
// b) Create a print method for the Tri class, similar to the print method
// for the Rect class. This method may come in very handy when debugging.
// 2.
// a) Create a header file (without a .cpp file) for a Shape class.
// b) Create the Shape class, which should have no member variables.
// c) Make the Shape class an interface for the Rect and Tri classes. Shape
// should have pure-virtual methods for each method that Rect and Tri have
// in common.
// d) Make sure Shape has a virtual destructor with an empty body.
// 3. Make Rect and Triangle extend Shape
// 4. Change selected
// a) Change the type of "Application :: selected" from "void *" to "Shape *".
// b) Every piece of code that typecasts "selected" (and the logic around it)
// can be removed now. Simply call functions using the "Shape" interface.
// c) Remove the "selectedType" variable from Application. Logic that needs
// some form of runtime type information should use dynamic_cast instead.
// 5. Merge all Shape objects into a single array
// a) Create an array of Shape pointers in the Application called "shapes".
// b) Making a complementary NUM_SHAPES variable would make sense.
// b) Remove "rectangles" and "triangles" arrays.
// c) Put each Tri and Rect object managed by the Application class into
// the "shapes" array. This will require re-factoring in multiple files.
// While removing references to "rectangles" and "triangles" arrays, it
// may make sense to replace pairs of for-loops using each of the old
// arrays with a single for-loop using just "shapes".
// 6. Make "shapes" dynamic
// a) Give Application :: init () 2 parameters: int numRect, int numTri
// b) Make "shapes" a pointer of type "Shape **", and allocate it to be
// "numShapes" big, where "numShapes" is an int member of Application
// equal to (numRect + numTri), defined in Application :: init ().
// c) When calling "app.init ()" in main, pass valid arguments for numRect
// and numTri.
// d) De-allocate the "shapes" array in Application :: Release ().
// 7. Clean up old variables

 

Diskussion