Skip to content

Latest commit

 

History

History
31 lines (16 loc) · 1.51 KB

README.md

File metadata and controls

31 lines (16 loc) · 1.51 KB

APCS1-LAB02

You must write three methods, and write many tests for each. Do not forget to test empty strings where appropriate.

Methods to write:

  1. myIndexOf()

  2. myCompareTo()

  3. 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.

Commits

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.

Directions

  1. 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")

  2. Write and test myIndexOf

  3. Write some test cases for myCompareTo using the builtin methods to compare the results to.

  4. Write and test myCompareTo

  5. Now you will write test cases for, and create one more method: int parseInt(String). Place it in the StringMethods.java file.