Access over 35 million academic & study documents

4 Start Implementing the operations of the Text class (only the bod

Content type
User Generated
Showing Page:
1/3
4. Start Implementing the operations of the Text class
(only the body of methods) 4.1. Implement default
constructor: Text::Text ( const char *charSeq ){} 4.2.
Implement copy constructor: Text::Text ( const Text &other
){} 4.3. Implement operator =: void Text::operator = (
const Text &other ){} 4.4. Implement destructor:
Text::~Text (){} 4.5. Implement getLength(): int
Text::getLength () const {} 4.6. Implement operator []:
char Text::operator [] ( int n ) const {} 4.7. Implement
clear(): void Text::clear () {} 4.8. Implement
showStructure():void Text::showStructure () const {} 5.
Compile your implementation of the Text ADT in the file
Text.cpp and the test program in the file test1.cpp. 6. Test
your implementation using the program in the file
test1.cpp. 7. Implement more methods: 7.1. Implement
toUpper(): Text Text::toUpper( ) const {} 7.2. Implement
toLower(): Text Text::toLower( ) const {} 8. Activate test
1 in the program test1.cpp by changing the definition of
LAB_TEST1 from 0 to 1 in config.h and recompiling. 9.
Implement more operators: 9.1. Implement operator ==:
bool Text::operator == ( const Text& other ) const {} 9.2.
Implement operator <: bool Text::operator < ( const Text&
other ) const {} 9.3. Implement operator >: bo ol
Text::operator > ( const Text& other ) const {}
Solution
#ifndef TEXT_H #define TEXT_H #include #include
using namespace std; class Text { public: //
Constructors and operator= Text ( const char *charSeq

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/3
= \"\" ); // Initialize using char* Text ( const
Text &other ); // Copy constructor void
operator = ( const Text &other ); // Assignment //
Destructor ~Text (); // Text operations int
getLength () const; // # characters char
operator [] ( int n ) const; // Subscript void
clear (); // Clear string // Output
the string structure -- used in testing/debugging void
showStructure () const; //--------------------------------------
------------------------------ // In-lab operations //
toUpper/toLower operations (Programming Exercise 2)
Text toUpper( ) const; // Create upper-
case copy Text toLower( ) const; //
Create lower-case copy // Relational operations
(Programming Exercise 3) bool operator == ( const
Text& other ) const; bool operator < ( const Text& other
) const; bool operator > ( const Text& other ) const;
private: // Data members int bufferSize; // Size of
the string buffer char *buffer; // Text buffer containing
a null-terminated sequence of characters // Friends //
Text input/output operations (In-lab Exercise 1) friend
istream & operator >> ( istream& input, Text& inputText );
friend ostream & operator << ( ostream& output, const
Text& outputText ); }; #endif #include > #include
Text::Text( const char *charSeq) { bufferSize =

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/3

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
4. Start Implementing the operations of the Text class (only the body of methods) 4.1. Implement default constructor: Text::Text ( const char *charSeq ){…} 4.2. Implement copy constructor: Text::Text ( const Text &other ){…} 4.3. Implement operator =: void Text::operator = ( const Text &other ){…} 4.4. Implement destructor: Text::~Text (){…} 4.5. Implement getLength(): int Text::getLength () const {…} 4.6. Implement operator []: char Text::operator [] ( int n ) const {…} 4.7. Implement clear(): void Text::clear () {…} 4.8. Implement showStructure():void Text::showStructure () const {…} 5. Compile your implementation of the Text ADT in the file Text.cpp and the test program in the file test1.cpp. 6. Test your implementation using the program i n the file test1.cpp. 7. Implement more methods: 7.1. Implement toUpper(): Text Text::toUpper( ) const {…} 7.2. Implement toLower ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4