CS 1037留学生作业代做、代写C/C++语言作业、代写polymorphism作业、代做C/C++程序作业
CS 1037 A (2018)Assignment 3Due: December 2, 11:55pmWeight: 10% of final gradeOverviewThis assignment is designed to test your ability to use classes (polymorphism). As well asdevelop good programming practices and briefly use the c++ container class: forward_list.You may freely use code from my lecture slides and from the code folder in OWL.Your program will take command line arguments and interpret them to produce a bitmapdrawing image.NO error checking is required – assume the command line arguments are well formedaccording to the specifications!Submission Requirements* Submission MUST be done through OWL.* See the syllabus for late penalties.* You will be submitting the following 2 files, named exactly:“assn3.cpp”“Drawable.h”* You may include any non-container standard c++ header files (ie. cstdlib).* Submission files will NEVER be zipped.* If your code does not run as-is in Microsft Visual Studio 2017, you will lose the majority ofyour marks.* You will not receive any marks for following these instructions, but marks will be deductedfor not following them. * ANY resubmission after the due date will incur the appropriate late penalty, even if youroriginal submission was before the due due.Project SetupI recommend creating a “Empty Project” as you did in lab 2, and create your assn3.cpp file asyou did in the same lab. Unlike assignment 1, you MUST require the user to input a character to keepthe window open after the output has been produced. The assn3.cpp file will contain your mainfunction. You may create additional helper functions within assn3.cpp.You will create a single header file named: Drawable.h. You will be putting 4 classes into thissingle file: DrawObject, Point, Line, Shape. All functions will be inline, even if they are a line or 2more than the rule of 2 lines. The reason we are breaking our rule of 1 class/1 file and the rule ofthumb that only methods of 1 or 2 lines will be coded inline, is simply for marking and submissionconvenience.Download the attached Drawing.cpp and Drawing.h files and add it to your project. I stronglyrecommend you write a simple program to create a bitmap file with some drawings on it to test theclass first!Main Program Flow (Understand/code the classes before trying to write main!)These are the steps your main function must perform in sequential order:1. Create a Drawing object based on the program arguments.2. Create as many specific DrawObjects (Line,Point,Shape) as are requested by the program arguments,and store each of them in a single forward_list<DrawObject *>.3. Print out the number of Shapes that were created, using the static function you coded.4. Call the draw function for each DrawObject, remove it from the forward_list, and free the objectmemory.5. Save your image using the file name specified in the arguments, print out a message if it wassuccessful or not.6. Print out the number of Shapes that remain, using the static function you coded.7. Prompt the user for a character before closing.HINT: Creating helper functions to parse object or colour or coordinate information from theargument array can greatly reduce the size and complexity of your main program!Drawing InformationA typical drawing surface is represented by a 2 dimensional array of pixels. The origin (Row=0,Col=0)is the top left corner, and the pixel located at (Height-1,Width-1) is at the bottom right corner. Use theCOORD struct to reference pixel coordinates.A pixel can have a colour that is represented by a combination of (red,green,blue) values. Each colourcomponent (RGB) is a number from 0-255. Black=(0,0,0), White=(255,255,255), Pure Red=(255,0,0).Use the COLOUR struct to specify pixel colour.A bitmap is a format for storing image information. Files stored in this format normally have the“.bmp” extension. If you open the file that was produced by your program, your operating systemshould chose a default program to view the image.Command Line ArgumentsThe user of your program will supply command line arguments in the following format. You do notneed to verify that they follow this format. The TA will not be entering in garbage to mark yourassignment.1. The file name to store the bmp that your program creates2. Width in pixels of the image3. Height in pixels of the image4,5,6. The R G B values to be used as the background colour of the imageAfter these argments will appear from 0 to any number of drawing object information. Each object willuse it’s own set of argument formats. You must test the first argument to determine which object tocreate.DrawOject (Point)1. ‘P’2,3,4. The R G B values to be used as the pixel colour of the point.5,6. The ROW and COL coordinate values for the point.DrawOject (Line)1. ‘L’2,3,4. The R G B values to be used as the pixel colour of the line.5,6. The ROW and COL coordinate values for the start of the line.7,8. The ROW and COL coordinate values for the end of the line.DrawOject (Shape)1. ‘S’2,3,4. The R G B values to be used as the pixel colour of the line.5. The number of ROW,COL coordinates to follow (1 means a single row/col pair to follow)6-??. The ROW and COL coordinate value for 1 vertex of the shape, repeated as many times as wasspecified by argument 5.*** Use the sample input and output image to follow how to use these arguments ***forward_listThe C++ standard templated container, forward_list<>, provides similar functionality to theVector/vector class we have been using.Refer to http://www.cplusplus.com/reference/forward_list/forward_list/ for class and methoddocumentation.You will need the following methods for this assignment:* forward_list::forward_list - The empty constructor* forward_list::empty* forward_list::push_front* forward_list::front* forward_list::pop_frontYou may use any other functions from this class, so long as you ensure the program specifications aremet.DrawObject HierarchyEverything in this section will be placed in your Drawable.h file.DrawObjectThe base class of your heirarchy will be an abstract class named DrawObject. It will have aprivate COLOUR member and a protected vector<COORD>. You will create a single constructorwhich accepts a COLOUR. You will add a public getter method for the COLOUR. You will add a purevirtual “draw” method which returns void and accepts a reference to a Drawing object. Do not forgetto include “Drawing.h”, and implement any other required functions for having a pure virtual function(see lecture slides).PointPoint will be a derived class of DrawObject. It will have a single constructor which accepts aCOLOUR and a COORD for the point. The only other method will implement the pure virtual baseclass member:draw. This method will set the pixel at first COORD to the COLOUR using the baseclass getter.LineLine will be a derived class of DrawObject. It will have a single constructor which accepts aCOLOUR and 2 COORDs for the start and end points of the line. The only other method willimplement the pure virtual base class member:draw. This method will draw a line from the firstCOORD to the second COORD using COLOUR from the base class getter.ShapeShape will be a derived class of DrawObject. It will have a single constructor which accepts aCOLOUR for the lines of the shape. You will implement the pure virtual base class member:draw.This method will draw a line from each COORD to the next COORD, and then draw a line from thelast COORD to the first COORD, using COLOUR from the base class getter. You will also add apublic method which accepts a COORD object and adds it to the base class vector<COORD>.You will add a static counter to Shape so that you can ensure there are no memory leaks in yourprogram. Add a private static int for the count of Shapes. Initialize the variable in the same file, butafter the class declaration (see lecture slides if you’ve forgotten). Add a public static function to get thenumber of Shapes in existence (this will be called from main). Modify the Shape constructor anddestructor to update the number of Shapes.Sample input – outputCommand line arguments shown if your executable is named assn3.exe:assn3.exe test.bmp 200 100 127 127 127 S 255 0 0 4 10 10 10 190 90 190 90 10 S 0 255 0 350 100 55 105 55 95 L 0 0 255 60 30 80 100 L 0 0 255 80 100 60 170 P 0 0 0 25 70 P 0 0 025 130* You may cut and paste this from the top of the Drawing.h file comment (pdf cut and paste doesnot always work correctly)cout statements:Number of shapes:2Number of shapes:0test.bmp saved successfullyProduces a test.bmp file which looks like the following:QuestionsThis is a short assignment (approximately 70 lines in assn3.cpp and 40 in Drawable.h), but itwill require you to understand the lecture/slide material. Before asking questions, I expect you to havelooked up the relevant slide material and phrase your questions in relationship to a specific slide, or tonew reference information you are expected to look up for this assignment.Markinghttp://www.daixie0.com/contents/13/2093.html* If your code does not compile and execute, you will receive 0 marks for functional test cases.* Marks will be deducted for not following instructions. (Both formatting and functional)* Marks will be deducted for “messy” code – ie. Not properly indented.* Use of meaningful variable names where appropriate and comments for complex code is required.* I do not expect the code to be optimized, however, needless inefficiencies may be deducted.Code similarities are both violations of Academic Dishonesty for those sharingtheir code as for those using other's code. If you wish to help anotherstudent, explain concepts in words, draw diagrams, or refer the student to specificreference material. You are not helping by providing the code!Similarity detection software will be used on all assignments. Any students whoachieve a high score for improbable code similarities will receive a mark of 0. Inaddition, further Academic Dishonesty reporting may be performed, andadditional penalties applied.
因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:
微信:codinghelp