

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Assignment 6 for the cosc 051 course, which focuses on object-oriented programming using classes to encapsulate shape data and methods. Students are required to refactor their software from assignment 5, providing functions to set shape properties, draw, and animate shapes. Classes should include appropriate comments, and methods must specify return types, inputs, outputs, and assumptions. Students must also provide a technique to copy one shape object to another, either through a copy constructor or overloading the = operator.
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


COSC 051 -‐ Assignment 6 (Shapes Option) Classes and Object Oriented Programming For this assignment you are requested to refactor the software you wrote for Assignment 5. You will use a class to encapsulate all relevant data items and methods that represent a shape (line and circle). In general, your class definition should include all of the functions that set shape properties, drew, and animated your shapes in the previous project. Your class definition should include appropriate comments. At a minimum, the comments must specify the following: -‐ The return type for each method -‐ Input(s), output(s), and any assumptions for each method -‐ A description of the class' public interface Any class methods that do not modify internal class variables must be defined as const methods. All class data members must be private. Consequently, only class methods can modify class data members. Your program must provide a technique to copy one shape object to another shape object of the same class. One way to accomplish this is with a "copy constructor"; so you must provide one in your classes. The coding fragment below demonstrates how a copy constructor can be used in your program. CircleType myCircle2(myCircle1); This example assumes that CircleType is the class name and that myCircle 1 is a previously instantiated CircleType object. The declaration of myCircle 2 as shown above will instantiate a new CircleType object with data values copied from myCircle 1. Additionally, and for extra credit, you may overload the = operator to work as follows: CircleType myCircle1; // do stuff here to set center coordinates //and radius for myCircle CircleType myCircle2; myCircle 2 = myCircle1; //copies myCircle 1 data to myCircle 2
You may choose which functions from Assignment 5 to include as methods in your class. However, you must include as many methods as necessary to instantiate shape objects, set object properties, draw objects on screen, and animate objects. All functionality must be provided through class methods. Your program must instantiate and animate objects according to the following criteria: