Vous êtes sur la page 1sur 4

CPSC 121::Third Project Character Pictures

due 13 April 2014


Background: A CharacterPicture is a rectangular array of characters that can be printed, with or without a fra e! "or e#a ple, gi$en the following strings:
char* init[] = { Miami, in the, Autumn };

The unfra ed CharacterPicture would loo% li%e this:


Miami in the Autumn // unframed picture

and the fra ed CharacterPicture would loo% li%e this:


+------+ |Miami | |in the| |Autumn| +------+ // framed picture

To

a%e this tas%

ore interesting, we should be able to hori&ontally concatenate CharacterPictures:


// horizontal Concat. Of framed and unframed

Miami +------+ in the|Miami | Autumn|in the| |Autumn| +------+

and $ertically concatenate the :


+------+ |London| |in the| // vertical concat. of framed picture and (horiz. concat. Of unframed and framed |Fall | +------+ Miami !""""""! in the# Miami # Autumn#in the# #Autumn# !""""""!

and of course, we should be able to frame the resulting pictures, without restriction 'other than e$entually running out of screen space(
+--------------+ |!""""""! | |#$ondon# | |#in the# | |#%a&& # | |!""""""! | |Miami !""""""!| |in the#Miami #| |Autumn#in the#| | #Autumn#| | !""""""!| +--------------+ // FRAME of (vert. Concat. Of framed picture // and (horiz. Concat of unframed and framed

CP C 121::!hird pro"ect: Character Pictures #r$ %ill &cCarth'

due 13 April 2014 at midnight page 1 of )

!ask: (our task is to write a )*+,- class to implement this functionalit'$ (our class &. ! include d'namic memor' allocation /to store an arra' of char0 1s, each pointer of which points to one of the lines in the character picture$ Because 'our class allocates d'namic memor', it &. ! ha2e a cop' constructor, assignment operator, and destructor to manage this memor' properl'$ (our class must allow character pictures to 3e printed out as in the e4ample on page 1 of this pro"ect description: /15 unframed /25 framed /using 161 for the corners, 171 for the top83ottom, and 191 for the sides of the frame5
friend 'icture friend 'icture friend

/35 hori:ontall' concatenated /using operator9/55 /45 2erticall' concatenated /using operator;/55,
'icture operator#( 'icture con(t) p*, 'icture con(t) p+ operator)( 'icture con(t) p*, 'icture con(t) p+ ; ;

frame( 'icture con(t) p

and must allow these operations /framing, hori:ontal concatenating, and 2ertical concatenating5 to 3e com3ined without limit$ !he following /pri2ate5 function is recommended to help 'ou implement this pro"ect$ 88 copies all characters from other /starting at 0, 05 to this picture, 3ut starting at r, c
,oid -&oc.cop/( int r, int c, 'icture con(t) other ;

<emem3er, 'ou are using a 3lock of memor' accessed 3' a 1=d pointer to manipulate the 2=d arra'

Test program
con(t char* init[] = { 0Miami0, 0in the0, 0Autumn0 }; int main( { 'icture p( init, 1 cout 22 p 22 end&; ; ; ;

'icture p3framed = frame( p cout 22 p3framed 22 end&;

'icture 4 = frame( p3framed ) (p # p3framed cout 22 4 22 end&; 'icture r = (p3framed ) p cout 22 r 22 end&; 'icture r3framed = frame( r cout 22 r3framed 22 end&; } ( ee ne!t pa"e for E!ample output# # 4; ;

CP C 121::!hird pro"ect: Character Pictures #r$ %ill &cCarth'

due 13 April 2014 at midnight page 2 of )

Example Output (comments are not part of the output)


Miami in the Autumn !""""""! #Miami # #in the# #Autumn# !""""""! !""""""""""""""! #!""""""! # ##Miami # # ##in the# # ##Autumn# # #!""""""! # #Miami !""""""!# #in the#Miami ## #Autumn#in the## # #Autumn## # !""""""!# !""""""""""""""! !""""""!!""""""""""""""! #Miami ##!""""""! # #in the###Miami # # #Autumn###in the# # !""""""!##Autumn# # Miami #!""""""! # in the #Miami !""""""!# Autumn #in the#Miami ## #Autumn#in the## # #Autumn## # !""""""!# !""""""""""""""! !""""""""""""""""""""""""! #!""""""!!""""""""""""""!# ##Miami ##!""""""! ## ##in the###Miami # ## ##Autumn###in the# ## #!""""""!##Autumn# ## #Miami #!""""""! ## #in the #Miami !""""""!## #Autumn #in the #Miami ### # #Autumn #in the### # # #Autumn### # # !""""""!## # !""""""""""""""!# !""""""""""""""""""""""""! // thi i p

// thi

p$framed % frame( p #

// thi

& % frame( p$framed ' (p | p$framed# #

// thi

r % (p$framed ' p# | &

// thi

r$framed % frame( r #

#ue date: This project is due in appro#i ately two wee%s, on unda', 13 April 2014, at midnight$ *t in$ol$es designing, i ple enting, and testing a substantial progra for the subset of C++ that we are studying in this course, fro start to finish! (our su3mission will 3e a written pro"ect report, including 'our C66 source code and

CP C 121::!hird pro"ect: Character Pictures #r$ %ill &cCarth'

due 13 April 2014 at midnight page , of )

output, su3mitted electronicall' to !)!A*ium as a single P#> file$ *ote: -ou ma' wor% in pairs on this project! Should you wor% with a partner, please turn in one report with both na es! )mportant? The following types of sub issions are i per issible, and will recei$e a score of &ero! .ate sub issions / ail sub issions Source code that will not co pile without errors "alsified input0output or that doesn1t atch the source code! Sub issions that are plagiari&ed or that $iolate the below collaboration guidelines! ,ate su3missions: 2o late ho ewor%, labs, or project assign ents will be accepted under any circu stances 'score of 3(! 4on1t be late! 5hen wor%ing in labs or when wor%ing on projects, you will wor% in a collaborati$e en$iron ent, optionally with one partner! Partners ay wor% together freely! /ach group should co plete their own wor% the sel$es, with $ery li ited help fro other indi$iduals or sources! The following guidelines apply to collaboration with any person or resource 6other than 'our partner@! -ou should be able to e#plain any part of your sub ission, and be able to e#plain why you wrote what you did! *f wor%ing in a group, each e ber of the group should be able to e#plain any part of the sub ission, and not just be able to e#plain 7his or her7 subset! -ou ay help each other understand the assign ent and brainstor general solutions, but ust separate to de$elop your own detailed solution to the proble , and ust indi$idually type in your source code and project report! -ou ay, of course, gi$e each other technical support, for instance troubleshooting installing 8isual Studio or logging into T*TA2iu ! -ou can share docu ented facts, such as the return $alue of a particular library function! 9i$en these re:uire ents, any sub issions with identical e#cerpts, or e#cerpts that are identical up to superficial rearrange ents, will be considered highly suspect of plagiaris !

CP C 121::!hird pro"ect: Character Pictures #r$ %ill &cCarth'

due 13 April 2014 at midnight page ) of )

Vous aimerez peut-être aussi