You are to create your own version of a string class named myString.

myString will store a character string of up to 25 characters (how will you handle the error if you are to process more than 25 characters?).

The characters MUST NOT be stored in a string variable. The ONLY method allowed to use string variables are setString (input) and getString (output).

The "test stub" main program to test your myString will create two instances (minimum) of myString variables and allow the user to manipulate the string of data in each instance and execute the following methods by selecting actions from a command-line menu until user exits the program.

Constructor will initialize myString data to empty string.

You are to echo the program and user actions and results to a screen and an output file namedd (user enters file name) myStringLog.txt -

Output file example:

program action create myString instance1
myString instance1 contains empty string
program action create myString instance2
myString instance2 contains empty string
user action set instance1 value to 'CIS 200 IS FUN!'
program action instance1 updated to 'CIS 200 IS FUN!'
myString instance1 contains 'CIS 200 IS FUN!'
user action set instance2 value to 'CIS 200 IS THE BEST CLASS EVER'
program action instance2 not updated, ERROR: user data > 25 characters
myString instance2 contains empty string
...

Methods MUST NOT write messages to screen or output file.

You will also need to supply the following methods as part of your class (must include a reference methodStatus "status variable" parameter in any method that an error can occur in (e.g. addStart)):

size() - returns integer of how many characters are in the string? (empty string is size zero)

addStart(myString, methodStatus) - void method adds the string in the input parameter to the front of current string (what if it exceeds 25 characters?)

addEnd(myString, methodStatus) - void method adds the string in the input parameter to the end of the current string (what if it exceeds 25 characters?)

partString(startPos, length, methodStatus) - returns myString from current myString starting at startPos for length given (handle startPos < 0 as error, startPos = size returns null string, and handle startPos > size as error, if length > size - startPos i.e. less characters than requested can be returned return all available characters e.g. request length of 8 but only 4 characters from startPos to end of string return the 4 characters)

replPartString(myString, startPos, methodStatus) - void method replaces characters starting at startPos with input string - (what if exceeds 25 characters?)

replWholeString (myString, methodStatus) - void method replaces what is currently in string with input parameter string

emptyString() - boolean method that returns true if myString contains the empty string

fullString() - boolean method that returns true if myString contains exactly 25 characters

compareString(myString) - boolean method compares current value of string with input parameter string and returns true if both strings are equal

charAt(pos, methodStatus) - character method returns character at that position (what if beyond end of string? What if negative?)

initString() - void method resets/initializes string to null string

setString(string, methodStatus) - void method assigns string to myString data value

getString() - string method that returns value in myString in a string data value

printString() - prints myString data value to the monitor (not to the file)

Be sure to ask for the users name and include "welcome" and "thank you" messages on screen and output file to them.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.