Csc110 Program 3 - Mystring: Due: Dec 4 Points: 100
Csc110 Program 3 - Mystring: Due: Dec 4 Points: 100
Due: Dec 4 Points: 100 Write a class that performs similar operations as the Java String class. Use only private data members and public methods. Do NOT use any existing String methods from the Java String class in yString implementations. The only exception is the constructor!String newString" and toString( ) as described belo#. Do NOT use ArrayLists. . Data members$ array of %& characters si'e ( current number of characters in the array ethods$
MyString( ) Creates an array of 25 characters and sets size to 0. MyString( String newString ) Creates an array of 25 characters. Copies each character from newString into the array and sets the value of size. A ma imum of 25 characters can !e stored. "se only String methods length( ) and charAt( ) to write this method. MyString( #yString oldString ) Creates an array of 25 characters. Copies each character from newString into the array and sets the value of size. "se only String methods length( ) and charAt( ) to write this method.
String toString()
inde zero.
boolean contains(char ch)
$eturns true if and only if this #yString contains the char value. 'therwise false is returned. (his method is not case sensitive.
boolean equals(MyString anotherMyString)
$eturns true if this #yString contains the same characters as the #yString parameter o!)ect.
int compareTo(MyString anotherString)
Compares two #yString o!)ects. return *+ if this o!)ect is less than the parameter o!)ect. return 0 if the two #yStrings match return ,+ if this o!)ect is greater than the parameter o!)ect
int indexOf(char ch)
$eturns the inde within #yString of the first occurrence of the specified character. %f the character does not e ist& return *+.
int length()
$eturns the num!er of characters store in the array. void replace(char oldChar, char newChar) $eplaces all occurrences of oldChar with newChar. (his method is case sensitive.
Write a test Driver that thoroughly tests each method. User input is not necessary) Strings can be hard coded into the test Driver. Output from the test Driver should be descriptive !#hat is expected and actual results". Submit yString.*ava) TestDriver.*ava and a U + class diagram.