hw14 - Homework Design a Test Plan This homework is necessary preparation for the lab Your job is to design a test plan to test the following static

hw14 - Homework Design a Test Plan This homework is...

This preview shows page 1 - 3 out of 3 pages.

Homework: Design a Test PlanThis homework is necessary preparation for the lab.Your job is to design a test plan to test the following static method that converts a given NaturalNumberinto a Stringwith commas in a format similar to the one used by the method printWithCommasyou implemented in a previous lab:/*** Converts the given {@code NaturalNumber} to a {@code String} with commas.* * @param n* the number* @return the {@code String} with commas* @ensures toStringWithCommas = [String representation of n with commas]*/publicstaticString toStringWithCommas(NaturalNumber n) {assertn != null: "Violation of: n is not null";String num = n.toString();String comma = ",";String testing = "";intcount = 0;String total = "";for(inti = num.length()-1; i >= 0; i--){String str = String.valueOf(num.charAt(i));testing = testing.concat(str);count++;if(count == 3){testing = testing.concat(comma);count = 0;}}//System.out.println(testing.length());for(intj = testing.length()-1; j >= 0; j--){//System.out.println(testing.charAt(j));total = total.concat(String.valueOf(testing.charAt(j)));}returntotal;}
private

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture