program6 Overview: The purpose of this project is to create an object that will represent a text document and perform important operations on the document. You will declare and implement a class named...

The assignment information is in the file "program6-docs.pdf"


program6 Overview: The purpose of this project is to create an object that will represent a text document and perform important operations on the document. You will declare and implement a class named Document. The class should have several data members: a pointer to an array of characters that will contain the content of the document, the length of the document (actual number of characters in the document), and the size of the document (a static constant that will represent the maximum number of characters the document can contain). You can assume a maximum size of 5000. The Document class should have several member functions: • A constructor that will create the dynamic memory array for holding the document content. This constructor will initialize the content to an empty string and the length to 0. • A copy constructor that will create the dynamic memory array for holding the document content and copy the content of another Document object into this array. This constructor will initialize the length accordingly. • A destructor that deallocates the dynamic memory array. • A member function named length for returning the length of the document. • A member function named countWords for returning the number of words in the document. Words may be separated by multiple whitespaces or the punctuations (.,;:-). In addition, you should overload the following operators for the Document class: • The assignment (=) operator so that a Document object can be assigned into another one. You will need to perform a "deep copy". • The assignment (=) operator so that a literal string can be assigned into a Document object. • The extraction (>>) and insertion (<) operators="" for="" reading/writing="" the="" entire="" content="" of="" a="" document="" at="" once.="" •="" the="" subscript="" ([])="" operator="" for="" using="" a="" supplied="" index="" to="" access="" any="" valid="" character="" of="" the="" document.="" •="" the="" concatenation="" (+)="" operator="" for="" combining="" the="" contents="" of="" two="" documents="" into="" a="" new="" document.="" note="" that="" you="" may="" not="" use="" the="" c++="" string="" class="" while="" implementing="" the="" document="" class.="" your="" code="" should="" include="" exception="" handling="" for="" all="" appropriate="" methods.="" declare="" and="" implement="" the="" document="" class="" in="" separate="" header="" and="" implementation="" files.="" write="" client="" code="" in="" prog6.cpp="" for="" the="" following="" tasks.="" do="" not="" change="" the="" content="" of="" the="" input="" files="" since="" some="" tab="" spaces="" have="" intentionally="" been="" included="" in="" them.="" •="" instantiate="" a="" document="" object="" doc1="" so="" that="" it="" invokes="" the="" default="" constructor.="" •="" assign="" the="" string="" "shooting="" yourself="" in="" the="" foot;\n\n"="" to="" doc1="" using="" the="" overloaded="operator." •="" instantiate="" another="" document="" object="" doc2="" so="" that="" it="" invokes="" the="" copy="" constructor.="" •="" for="" each="" of="" the="" three="" input="" files,="" humor1.txt,="" humor2.txt,="" and="" humor3.txt,="" read="" the="" file="" content="" into="" doc1="" using="" the="" overloaded="">> operator and append the content of doc1 onto doc2 using the overloaded + and = operators. • Write the content of doc2 to a file named humor.txt and also to the console using the overloaded < operator.="" •="" display="" the="" number="" of="" words="" in="" doc2.="" •="" count="" and="" display="" the="" number="" of="" whitespaces="" in="" doc2="" using="" the="" overloaded="" []="" operator.="" instructions:="" •="" this="" is="" an="" individual="" programming="" project.="" •="" organize="" your="" code="" in="" document.h,="" document.cpp,="" and="" prog6.cpp.="" •="" use="" meaningful="" variable="" names,="" helpful="" comments,="" and="" a="" consistent="" coding="" style.="" deliverables:="" you="" will="" need="" to="" submit="" the="" following="" in="" blackboard="" by="" 11:59="" pm="" on="" november="" 20th:="" •="" the="" files="" document.h,="" document.cpp,="" and="" prog6.cpp,="" and="" the="" screenshot="" of="" your="" program="" execution="" in="" eclipse="" (as="" shown="" in="" the="" sample="" executions).="" grading:="" this="" assignment="" is="" worth="" 25="" points="" distributed="" as="" follows:="" •="" demo="" of="" part="" i="" (10="" pts)="" o="" successful="" declaration="" of="" the="" class="" document="" (2="" pts)="" o="" successful="" implementation="" of="" constructs="" and="" destructor="" (3="" pts)="" o="" successful="" implementation="" of="" two="" overloaded="" assignment="" operators="" (3="" pts)="" •="" part="" ii="" (10="" pts)="" o="" successful="" implementation="" of="" main="" (3="" pts)="" o="" full="" implementation="" of="" overloaded="">< and="">> (3 pts) o Full implementation of overloaded + and [] (2 pts) o Full implementation of countWords (2 pts) • Program Style (5 pts) o Meaningful variable names (1 pt) o Proper indentation (1 pt) o Sufficient comments (3 pts) Sample Executions: Shooting yourself in the foot; C: You shoot yourself in the foot and then nobody else can figure out what you did. C++: You accidentally create a dozen instances of yourself and shoot them all in the foot. Java: You amputate your foot at the ankle with a fourteen-pound hacksaw, but you can do it on any platform. # of words: 59 # of spaces: 118 C: You shoot yourself in the foot and then nobody else can figure out what you did. C++: You accidentally create a dozen instances of yourself and shoot them all in the foot. Java: You amputate your foot at the ankle with a fourteen-pound hacksaw, but you can do it on any platform.
Nov 14, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here