/* * Main.java * * Created: February 14, 2005 * By: Stan Sclaroff * Description: Main class to help test methods developed for * CS111 Spring 05 Programming Assignment 3 * */ package program3; public class Main { /** Creates a new instance of Main */ public Main() { } /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here MyString s = new MyString(); int count; // Tests of method wordCount System.out.println("Testing method wordCount"); count = s.wordCount("This is a test"); System.out.println(count + " should be 4"); count = s.wordCount("This1 puts it 2 the test!\n 4ever"); System.out.println(count + " should be 7"); count = s.wordCount("\t \n \r"); System.out.println(count + " should be 0"); count = s.wordCount("this-is-a-test."); System.out.println(count + " should be 4"); count = s.wordCount(""); System.out.println(count + " should be 0"); // Tests of method wordFrequency System.out.println("\nTesting method wordFrequency"); count = s.wordFrequency("is", "This is a test"); System.out.println(count + " should be 1"); count = s.wordFrequency("number", "1number = number1"); System.out.println(count + " should be 0"); count = s.wordFrequency("fuZZy", "Fuzz-Fuzzy-wuzzy was a bear?\n"); System.out.println(count + " should be 1"); count = s.wordFrequency("\n", "MARY, marry Oh Mary!"); System.out.println(count + " should be -1"); count = s.wordFrequency("", "1number = number1"); System.out.println(count + " should be -1"); } }