Starting from:
$35

$29

Project 01 Solution

1. Problem Statement




Create an original version of the ​string​class named ​myString​. Each instance of ​myString​will be able to handle 25 characters and each method will need to contain a reference “status variable”.




2. Requirements




2.1 Assumptions




Default ​string​class may be used for screen input
Default ​string​class may be used for ​setString​method



User will not input strings that include spaces



2.2 Specifications




Functions to replicate



size​()
addStart​()



addEnd​()



partString​()



replPartString​()



replWholeString​()



compareString​()



initString​()



setString​()



getString​()



printStringScreen​()



numericString​()



alphabeticString​()



Program will test each function systematically



Some results will be shown to the user



Some results will be printed to a file



May allow for methods to be tested out of order/individually



Decomposition Diagram



myString​Class Program

Input



User inputs string under 25 characters



User inputs via command line



Process



Count the number of characters in a string



Iterate character array to append beginning



Iterate through array to append to end



Replace part of array from given position



Replace entire array of characters



Compare given array with saved array



Initialize/Wipe string to ​null
Insert ​string ​into ​myString



Determine if string is integer or real number



Determine if string is alphabetic exclusively



Output



Iterate and return portion of string from any start point



Return and print current array of characters



Test Strategy



Valid Data



Invalid Data



Test Plan Version 1



Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail














Valid Data
1
size​()








Valid Data
2
addStart​()








Valid Data
3
addEnd​()








Valid Data
4
partString​()








Valid Data
5
replPartString​()








Valid Data
6
compareString​()








Valid Data
7
initString​()








Valid Data
8
setString​()








Valid Data
9
getString​()








Valid Data
10
printStringScreen​()








Valid Data
11
numericString​()








Valid Data
12
alphabeticString​()








Invalid Data
1
addStart​()








Invalid Data
2
addEnd​()








Invalid Data
3
partString​()








Invalid Data
4
replPartString​()








Invalid Data
5
replWholeString​()








Invalid Data
6
compareString​()








Invalid Data
7
setString​()








Invalid Data
8
getString​()








Invalid Data
9
printStringScreen​()

















Initial Algorithm



Create Class ​myString

Create Function ​size​()



Return number of characters in string



Count all non-null characters and add to ​total
Create Function ​addStart​(myString)



Add input to beginning of string



Move current characters forward and insert



Create Function ​addEnd​(myString)

Append string with input



Insert characters to end up to 25



Create Function ​partString​(startPos, length)

Return portion of string from inputted index



Take in index integer and iterate from there



Create Function ​replPartString​(myString, startPos)

Replace portion of string from inputted index



Take in index of string and replace
Create Function ​replWholeString​(myString)

Replace entire string with user input



Wipe string and insert characters



Create Function ​compareString​(myString)

Compare current string to user input



Iterate both and check each index



Create Function ​initString​()

Wipe/Initialize string to null



Iterate and clear each index



Create Function ​setString​(string)

Set string to current input



Iterate and fill each index with corresponding index



Create Function ​getString​()

Return current string



Iterate and return each index into string



Create Function ​printStringScreen​()

Print current string to screen



Iterate and print each index



Create Function ​numericString​()

Determine if string is integer or real number



Iterate and check for numeric or real number characters in correct order



Create Function ​alphabeticString​()

Determine if string is all alphabetic



Iterate and check for alpha characters



Create Function ​outputFile​()

Will print results of each function in class ​myString​to file



MAIN ​FUNCTION



Test each function of class ​myString



Print results of each function to file with ​outputFile​().



Test Plan Version 2



Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail














Valid Data
1
size​()
“string”
6




Valid Data
2
addStart​()
“my“
“mystring”




Valid Data
3
addEnd​()
“s”
“mystrings”




Valid Data
4
partString​()
0, 5
“mystr”




Valid Data
5
replPartString​()
3, “Test”
“myTest”




Valid Data
6
compareString​()
“mystring” “test”
FALSE




Valid Data
7
initString​()
null
null string




Valid Data
8
setString​()
“mystr” ​string
“mystr” ​myString




Valid Data
9
getString​()
“mystr” ​myString
“mystr” ​string




Valid Data
10
printStringScreen​()
“mystr”
“mystr” Print




Valid Data
11
numericString​()
“6.502”
TRUE




Valid Data
12
alphabeticString​()
“abc”
TRUE




Invalid Data
1
addStart​()
“abcd...z”
overflow




Invalid Data
2
addEnd​()
“zyxw...a”
overflow




Invalid Data
3
partString​()
“-1, 5”
Invalid Index




Invalid Data
4
replPartString​()
“my“, -1
Invalid Index




Invalid Data
5
replWholeString​()
“abc...z”
overflow




Invalid Data
6
compareString​()
“”
null




Invalid Data
7
setString​()
“”
null




Invalid Data
8
getString​()
“”
null - empty




Invalid Data
9
printStringScreen​()
“”
null - empty
























































































12. Error Log







Error Type (Logic/Runtime)
Cause of Error
Solution to Error






Logic
Casting charArray to double
None at the moment.


within numericString() give




correct answer every time




except with input = 0

















13. Status




Program is working.

More products