CPSC2620 Fall 2010 Assignment 1 Total points: 100 points Due date: Part I - Sept 23 (11:59 pm) Part II Sept 27 (11:59 pm) Part III Sept 29 (11:53 pm) This assignment is concerned with writing a program (C++ class/classes) and a test program that allow the users to draw shapes called "character pictures" using ascii characters. A character picture is a rectangular array of characters that can be displayed on to a computer screen. For example, if the character picture object named cpic has been initialized with the strings "this is an" and "example" then when displayed on a computer screen, it may appear as: this is an example Note that the two strings are displayed (on your computer screen) in two rows (lines) and that the strings are left-aligned. The first string "this is an" has 10 characters (including the blanks within it) while the second string has 7 characters. When displaying the strings as a picture the strings (in the above the string "example") that have fewer characters than the longest string (in the above "this is an") are padded with space character to make them the same length. A character picture can be "framed". For example, if we have a picture containing the strings "this is an" "example" then after framing with the frame character "*" the picture will be displayed as ************** * this is an * * example * ************** Note that the text and the frame are separated by a space character on the left- and the right-margin. A picture object, say rightpic, can be added to the right of another picture object, say leftpic, and the result is a new picture where leftpic forms the left part and rightpic forms the right part of the new picture; leftpic and rightpic are not modified. We call the operation addRight. The picture ************************** * this is an this is an * * example example * ************************** is the result of the operation addRight of ************** * this is an * * example * ************** to itself. A picture object, say bottompic, can be added below another picture object, say toppic, and the result is a new picture where toppic forms the top part and bottompic forms the bottom part of the new picture; toppic and bottompic are not modified. We call the operation addBelow. The picture ************** * this is an * * example * * this is an * * example * ************** is the result of the operation "addBelow" of ************** * this is an * * example * ************** to itself. Write a class named CharacterPicture such that users of the class can do the following. 1. Creates character pictures by reading character strings from (a) the command line or (b) from a given file containing character strings, one string per line, and an optional frame character. If no frame character is provided, a default frame character is to be used. You must choose and explain your choice of an appropriate character as a default value for the frame. 2. A character picture object can also be created (a) as a copy of another character picture object, and (b) as an "empty" character picture. 3. Displays a picture on the computer screen with or without the frame character. 4. Implements the functions addRight and addBelow as explained. 5. Stores pictures as character strings in a file. 6. Any other member functions that you feel necessary (you must justify why they are needed). 7. A test program to show that each member function of your class works correctly. Submission: We will use an incremental submission scheme for this assignment as detailed below. This submission style allows you to correct mistakes (on your earlier submissions) and therefore gives you opportunities to improve your score. Further, you now have the opportunity to get part marks for your assignments. (I) In the first part of your submission you only provide the class definition (.h file) and a dummy implementation file (.cc) containing functions without implementation. This part is weighed 20%. (II) In the second part of your submission you provide class definition (.h) which may have been modified/improved from submission (I) and the implementation (.cc) answering questions 1(a), 2(b), 3, 4, and 7. This part is weighed 50%. (II) In the third part of your submission you provide the complete solution to all the questions. This part is weighed 30%. Marks will be awarded as follows. 1. Correctly implements the member functions: 40 points. 2. Class definition meets the problem specification: 10 points. 3. The code is properly commented: 20 points. 4. The program employs good coding style: 10 points. 5. The test program tests all member functions for both correct and incorrect inputs: 20 points. Total: 100 points