You must write three methods, and write many tests for each. Do not forget to test empty strings where appropriate.
-
myIndexOf()
-
myCompareTo()
-
int parseInt(String) : This method will take a string like "123" and return the value 123. You may assume that the String is formatted like a valid integer. The string contains only digits, optionally starting with a '-', and the range of values that work is between -(2^31) + 1 and 2^31 - 1) inclusive. The min value of an int is excluded since you cannot make the positive version and negate it. I will not test this value, but there is an easy workaround for it.
Negative numbers should work for parseInt() but you should worry about that last after you get non negative numbers working.
For this lab be sure to commit regularly (any time you make meaninful progress or improve your methods) This means multiple (more than 2) commits in class, and multiple (more than 2) commits at home each day until you are done.
Make sure you commit with meaningful messages.
-
Write some test cases for myIndexOf using the builtin methods to compare the results to. e.g. Call both "Hello".indexOf("el") and StringMethods.myIndexOf("Hello","el")
-
Write and test myIndexOf
-
Write some test cases for myCompareTo using the builtin methods to compare the results to.
-
Write and test myCompareTo
-
Now you will write test cases for, and create one more method: int parseInt(String). Place it in the StringMethods.java file.