As stated to support. This is a C++ assignment, STL library is not allowed, "Using namespace std;" instead of adding "std::" is required. Most of the files are given and its just implementation. CS...

As stated to support. This is a C++ assignment, STL library is not allowed, "Using namespace std;" instead of adding "std::" is required. Most of the files are given and its just implementation.

CS 202 – Assignment #5 Purpose: Learn class inheritance, pointers, dynamic memory allocation, class implementation, virtual functions, and make utility. Points: 100 Assignment: Design and implement a C++ class to plot a spirograph1 drawing. Imagine the movement of a small circle that rolls on the outside of a rigid circle. Imagine that the small circle has an arm, rigidly attached, with a plotting pen fixed at some point. That is a epicycloid, commonly called spirographs. ● Spiro Class The spiro class will implement a spirograph class to provide basic Spirograph drawing functions. The spiroType class should inherit the bitmap image functions from the bitmapImage class (which includes creation of the formatted BMP image files). SpiroType : private bitmapImage -radiusFixed: double -radiusMoving: double -offsetAmount: double -drawColor: string -fileName: string +W_MIN, W_MAX, H_MIN, H_MAX: const int +spiroType() +spiroType(int, int, string) +spiroType(const spiroType&) +createSpiroImage(): void +readImageSize(): void +readFileName(): void +setFileName(string): void +setImageSize(int, int): void +initImage(int): void +createImageFile(): void +setParameters(double, double, double, string): void +readParameters(): void +getRadiusFixed() const: double +getRadiusMoving() const: double 1 For more information, refer to: http://en.wikipedia.org/wiki/Spirograph rF rM oA +getOffsetAmount() const: double +getDrawColor() const: string +getHeight() const: int +getWidth() const: int +getFileName() const: string +getPixel(int, int) const: int You may add additional private functions as needed. You are not allowed to add any additional class variables. Function Descriptions • The default constructor (no parameters) should call the base class and set the file name to a null string. The non-default constructor should accept the width, height, and file name string (in that order) and call the base class constructor. The copy constructor should create a new object from the passed object (i.e., deep copy). • The readFileName() function should read a file name from input, and ensure that it has a '.bmp' extension. Re-prompt if there is an error. The setFileName(string) function sets the file name class variable. • The readImageSize() function should read the width and height from input and ◦ ensure width is between W_MIN (100) and W_MAX (10000) ◦ ensure height is between H_MIN (100) and H_MAX (10000) ◦ ensure the aspect ratio (width/height) is between 1.0 and 2.0 and set the base class width and height variables accordingly. The setImageSize(int,int) function set the base class width and height variables (in that order) accordingly. The function should read both values and re-prompt as needed. • The initImage(int) function should fill the entire image with the provided color (by using the appropriate base class functions). • The setParameters(double,double,double,string) function sets the class variables for radiusFixed, radiusMoving, offsetAmount, and drawColor (in that order). • The readParameters() should read from the user, set the class variables for radiusFixed, radiusMoving, offsetAmount, and drawColor (in that order). If an invalid value is entered, an error message should be displayed and the user re-prompted. The radius and offset values must be between 0.0 and the minimum of image height or image width. • The createImageFile() function creates the image file using the class variable for file name with a 24-bit depth (by using the appropriate base class functions). • The getWidth(), getHeight(), getPixel(int,int), getRadiusFixed(), getRadiusMoving(), getOffsetAmount(), and getDrawColor() functions return the appropriate values or performs the appropriate function accessing the base class functions as necessary. • The createSpiroImage() function should create the Spirograph (epicycloid) drawing. The formulas for an epicycloid is as follows: x = [(rF+ rM) × cos(t)] + [ oA × cos( (rF + rM) ∗ t rM )] y = [(rF+ rM) × sin(t)] + [ oA × sin( (rF + rM) ∗ t rM )] Where, rF is radiusFixed, rM is radiusMoving, oA is and offsetAmount. The value for t represent all 360 degrees of a circle (i.e., starting at 0.0, stop at 360.0) and incrementing by 0.01. Before plotting, the (x,y) point must be cast as an integer and offset to the center of the screen (i.e., x += width/2 and y += height/2). ● Bit Map Image Class There are many programs that can write information to a simple, device and OS independent bitmap image format. The bitmapImage class (bitmapImage.h and bitmapImage.o) provides a simple interface for the creation of an uncompressed, BMP bitmap file. bitmapImage -width: int -height: int -**pixelData: int -freePixelData() +bitmapImage() +bitmapImage(const char*) +bitmapImage(int, int) +~bitmapImage(): virtual +setSize(int, int): void +loadFromBitmapFile(const char*): int +saveToBitmapFile(const char*) const: void +saveToBitmapFile(const char*, int) const: void +getHeight() const: int +getWidth() const: int +getRed(int colour) const: int +getGreen(int colour) const: int +getBlue(int colour) const: int +getColourForRGB(int, int, int) const: int +getPixel(int, int) const: int +setPixel(int x, int y,int colour): void +fillWith(int colour): void +fillRect(int, int, int, int, int): void +setPixelRGB(int, int, int, int, int): void The class header and object files will be provided on the class web site. The header file includes documentation for the class functions. Note, this class may be used for future assignments. Refer to the example executions for output formatting. Make sure your program includes the appropriate documentation. See Program Evaluation Criteria for CS 202 for additional information. Make File: You will need to develop a make file for future assignments. With the provided make file, you can type make Which will create the spiro executable. The makefile will be very similar to the previous assignment makefiles. Prompts and Error Messages The following are the applicable prompt and error messages. If there is an error with the input value, each function should re-prompt until valid values are obtained. Constructor: cout <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>


May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here