Perfect Essay Writing

GSP 125 Week 5 iLab Shapes

Order ready-to-submit essays. No Plagiarism Guarantee!

Note:  All our papers are written from scratch by human writers to ensure authenticity and originality.

GSP 125 GSP/125 GSP 125 Week 5 iLab

Check your essay before you submit. See exactly what your professor sees.

See your AI and plagiarism results before your instructor does.Get the exact same report your professor uses. Trusted by 50,000+ students worldwide.

// INSTRUCTIONS

// ————

// Compile this code. After pressing any key to clear the instructions, You

// should see three rectangles labeled ‘#’, ‘b’, and ‘c’. You should also see

// two triangles, labeled ‘d’ and ‘e’. Pressing ‘>’ and ‘<‘ will change which

// shape is labeled ‘#’. Pressing ‘w’, ‘a’, ‘s’, and ‘d’ will move the shape

// labeled ‘#’. Pressing ‘space’ will randomize the selected shape.

//

// Read through this code! Try to understand it before starting the assignment.

// Comment confusing lines with what you think code is doing, and experiment

// with existing code to test your understanding.

// Once you feel comfortable with this code, accomplish each of the following,

// and make sure your code compiles and runs after each step is completed.

//

// 1. Getting comfortable with the code

// a) Create 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. Create Shape base class

// 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

// a) Remove the TYPE_RECT and TYPE_TRI variables from Application.

// b) Remove NUM_TRI and NUM_RECT, and any NUM_SHAPES variable as well. Use

// numShapes where needed.

// 8. Add Circle class

// a) Create a header file AND a source file for a Circle class.

// b) Use Rect and Tri as examples to create the Circle class with.

// c) A Circle class should have at least a 2 dimensional position, and a

// radius.

// d) A simple algorithm for drawing a Circle will be similar to drawing a

// Rect or Tri, thought it might include the following code:

// float dx = center.x – col, dy = center.y – row;

// if( dxdx + dydy <= radius * radius ) {

// moveCursor(col, row);

// putchar(letter);

// }

// e) Add an additional parameter to Application::init(), “int numCircles”.

// Implement init to generate Circle objects along with Rect and Tri

// objects.

// 9. Implement add/remove for the shapes array

// a) Add code that increases the size of the shapes array, adding a random

// shape, whenever the ‘=’ or ‘+’ key is pressed. Take a look at the week

// 5 lecture showing explicit constructors for help with this algorithm.

// a) Add code that decreases the size of the shapes array, removing the last

// shape, whenever the ‘-‘ or ‘_’ key is pressed. End the program when the

// last shape is removed. Removing a shape, like adding a shape, can be

// done by allocating an array of a different size (smaller this time).

SOURCE: WWW.ROYALRESEARCHERS.COM
Havent found the Essay You Want?
We Can Help
The Essay is Written From Scratch for You

🛒Place Your Order

ORDER AN ESSAY WRITTEN FROM SCRATCH at : https://royalresearchers.com/
PLACE YOUR ORDER
Share your love