The purpose of this assignment is to practice: ▪Implementing a sequential abstract data type that uses a dynamic array structure ▪Analyzing and comparing algorithms for efficiency using Big-O notation This assignment reinforces the following competency: Apply the fundamentals of mathematics in computer science disciplines. For this assignment, implement a version of the string class. Design and implement a MyString class defined by the following data: ▪A char array reference (or pointer) for the array of characters that make up the string ▪An integer curr_length representing the number of characters in the string ▪(C++ only) An integer capacity that represents the size of the array Add the following methods to your class: ▪A constructor that initializes the array to null and the curr_length to 0 ▪A constructor that takes a String parameter and initializes the char array to the characters in the String. curr_length should be appropriately initialized. ▪a copy constructor that takes a MyString object and initializes a new MyString object so that it is a copy of the argument string ▪a length() method that returns the number of characters in the string ▪a private method, ensureCapacity(), that handles allocation of additional memory for the string ▪a toString() method that returns a String representation of the MyString object (Java), or overload the insertion operator (<<) (C++). ▪a concat(MyString) method that takes a MyString parameter and returns a MyString object that is a concatenation of the calling object and the parameter (Java) or overload the + operator (C++) ▪a .equals(MyString) method that takes a MyString parameter and returns true if this MyString and the parameter are the same (Java) or overload the == operator (C++) ▪a .compareTo(MyString) method that takes a MyString parameter and returns as follows (Java) o0 if the parameter and this MyString are the same oA negative integer if this MyString is alphabetically before the parameter oA positive integer if this MyString is alphabetically after the parameter OR Overload the < and > operators (C++) ▪.get(int) method that takes an integer and returns the character at that index location. PRE: the integer must be in range (Java) OR overload the index operator (C++) ▪.toUpper() and .toLower() that return a MyString that is in all upper case (or lower case) ▪.substring(int) that takes an integer and returns the substring starting at that index. ▪.substring(int n, int m) . Return a MyString substring where n is the starting index and m is one past the ending index. ▪.indexOf(MyString) and .lastIndexOf(MyString) that take a MyString parameter and return the starting index of the first (or last) occurrence of the MyString in the calling object. If the parameter is not found in the calling object, the method should return -1.   1.Create a driver program that tests your MyString class. 2.Record a Loom video in which you: a.Offer runtime analysis for the algorithms in your MyString class. b.Explain the mathematics used to calculate the number of steps required for each of your algorithms. c.Discuss any difficulties or points of interest in your implementation of the MyString class. Your driver program should test ALL of the functions in your MyString class and should be easy to follow. Here is an example of a partial driver program that is easy to follow

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Project 1: MyString
The purpose of this assignment is to practice:
▪Implementing a sequential abstract data type that uses a dynamic array structure
▪Analyzing and comparing algorithms for efficiency using Big-O notation
This assignment reinforces the following competency: Apply the fundamentals of mathematics in computer science disciplines.
For this assignment, implement a version of the string class.
Design and implement a MyString class defined by the following data:
▪A char array reference (or pointer) for the array of characters that make up the string
▪An integer curr_length representing the number of characters in the string
▪(C++ only) An integer capacity that represents the size of the array
Add the following methods to your class:
▪A constructor that initializes the array to null and the curr_length to 0
▪A constructor that takes a String parameter and initializes the char array to the characters in the String. curr_length should be appropriately initialized.
▪a copy constructor that takes a MyString object and initializes a new MyString object so that it is a copy of the argument string
▪a length() method that returns the number of characters in the string
▪a private method, ensureCapacity(), that handles allocation of additional memory for the string
▪a toString() method that returns a String representation of the MyString object (Java), or overload the insertion operator (<<) (C++).
▪a concat(MyString) method that takes a MyString parameter and returns a MyString object that is a concatenation of the calling object and the parameter (Java) or overload the + operator (C++)
▪a .equals(MyString) method that takes a MyString parameter and returns true if this MyString and the parameter are the same (Java) or overload the == operator (C++)
▪a .compareTo(MyString) method that takes a MyString parameter and returns as follows (Java)
o0 if the parameter and this MyString are the same
oA negative integer if this MyString is alphabetically before the parameter
oA positive integer if this MyString is alphabetically after the parameter
OR
Overload the < and > operators (C++)
▪.get(int) method that takes an integer and returns the character at that index location. PRE: the integer must be in range (Java) OR overload the index operator (C++)
▪.toUpper() and .toLower() that return a MyString that is in all upper case (or lower case)
▪.substring(int) that takes an integer and returns the substring starting at that index.
▪.substring(int n, int m) . Return a MyString substring where n is the starting index and m is one past the ending index.
▪.indexOf(MyString) and .lastIndexOf(MyString) that take a MyString parameter and return the starting index of the first (or last) occurrence of the MyString in the calling object. If the parameter is not found in the calling object, the method should return -1.
 
1.Create a driver program that tests your MyString class.
2.Record a Loom video in which you:
a.Offer runtime analysis for the algorithms in your MyString class.
b.Explain the mathematics used to calculate the number of steps required for each of your algorithms.
c.Discuss any difficulties or points of interest in your implementation of the MyString class.
Your driver program should test ALL of the functions in your MyString class and should be easy to follow. Here is an example of a partial driver program that is easy to follow
### Understanding Basic String Operations in C++: An Example

#### Command Line Output

```
Test program...
s1 = 'Bilbo Baggins' and s2 = 'hotdog'

        testing copy constructor - copying s1 to new string s3...
s1 = 'Bilbo Baggins' and s3 = 'Bilbo Baggins'

        testing the = operator - assigning s3 to s2...
s2 = 'Bilbo Baggins' and s3 = 'Bilbo Baggins'

        testing .length()...
there are 13 characters in 'Bilbo Baggins'

        testing < operator...
'chicken' < 'chimp' evaluates to true.

Press any key to continue . . .
```

#### Explanation

This command line output demonstrates basic string operations in C++. The operations include initializing strings, using the copy constructor, assignment operator, length method, and comparison operator. Here’s a detailed breakdown of each operation:

1. **Initialization**:
    ```cpp
    s1 = 'Bilbo Baggins' and s2 = 'hotdog'
    ```
    - Strings `s1` and `s2` are initialized with the values `'Bilbo Baggins'` and `'hotdog'`, respectively.

2. **Copy Constructor**:
    ```cpp
    testing copy constructor - copying s1 to new string s3...
    s1 = 'Bilbo Baggins' and s3 = 'Bilbo Baggins'
    ```
    - A new string `s3` is created by copying the value from `s1`.
    - `s3` now contains the same value as `s1`, which is `'Bilbo Baggins'`.

3. **Assignment Operator**:
    ```cpp
    testing the = operator - assigning s3 to s2...
    s2 = 'Bilbo Baggins' and s3 = 'Bilbo Baggins'
    ```
    - The value of `s3` is assigned to `s2`.
    - Both `s2` and `s3` now contain `'Bilbo Baggins'`.

4. **Length Method**:
    ```cpp
    testing .length()...
    there are 13 characters in 'Bilbo Baggins'
    ```
    - The `.length()` method is used to determine the number of characters in the string `s1`.
    -
Transcribed Image Text:### Understanding Basic String Operations in C++: An Example #### Command Line Output ``` Test program... s1 = 'Bilbo Baggins' and s2 = 'hotdog' testing copy constructor - copying s1 to new string s3... s1 = 'Bilbo Baggins' and s3 = 'Bilbo Baggins' testing the = operator - assigning s3 to s2... s2 = 'Bilbo Baggins' and s3 = 'Bilbo Baggins' testing .length()... there are 13 characters in 'Bilbo Baggins' testing < operator... 'chicken' < 'chimp' evaluates to true. Press any key to continue . . . ``` #### Explanation This command line output demonstrates basic string operations in C++. The operations include initializing strings, using the copy constructor, assignment operator, length method, and comparison operator. Here’s a detailed breakdown of each operation: 1. **Initialization**: ```cpp s1 = 'Bilbo Baggins' and s2 = 'hotdog' ``` - Strings `s1` and `s2` are initialized with the values `'Bilbo Baggins'` and `'hotdog'`, respectively. 2. **Copy Constructor**: ```cpp testing copy constructor - copying s1 to new string s3... s1 = 'Bilbo Baggins' and s3 = 'Bilbo Baggins' ``` - A new string `s3` is created by copying the value from `s1`. - `s3` now contains the same value as `s1`, which is `'Bilbo Baggins'`. 3. **Assignment Operator**: ```cpp testing the = operator - assigning s3 to s2... s2 = 'Bilbo Baggins' and s3 = 'Bilbo Baggins' ``` - The value of `s3` is assigned to `s2`. - Both `s2` and `s3` now contain `'Bilbo Baggins'`. 4. **Length Method**: ```cpp testing .length()... there are 13 characters in 'Bilbo Baggins' ``` - The `.length()` method is used to determine the number of characters in the string `s1`. -
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Recurrence Relation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education