jblight
April 23rd, 2008, 12:03 AM
Hello everyone, i am new here and have come in search for desperate help/assistance. I have recently been given the following project.
This project involves implementing two classes called WordCount1 and WordCount2 (for Exercises 1 and 2 respectively). Both classes may be created in the one project called WordCount. Both classes count the number of occurrences of each word or phrase from a given input array of Strings. Your classes should process the given input array to produce the information regarding the occurrence of each word (this will be done in storeWords() below). The following methods should be implemented in both classes:
1. storeWords(String[] array) which iterates through a given passed array storing unique words/phrases and the number of times they were found in the array. This method will be called from the test class outlined in Exercise 3.
2. printWords() which will print out all unique words and their number of occurrences. Words can be printed out in any order.
3. topFourWords() which will print out the four words that have the most number of occurrences. These words will be printed in descending order of occurrence.
Now the given array to be used is
private String[] array = {"ICT", "School", "2B", "pencil", "2B", "2B", "project", "quiz", "pencil", "2B", "quiz", "pencil", "quiz", "2B", "I", "programming", "student", "star", "apple", "queen", "such", "access", "JJJ", "student", "project", "star", "orange", "summer", "spring", "hello", "access", "pencil", "programming", "elbow", "apple", "quiz", "pear", "orange", "around the horn", "such is life", "access", "ICT", "winter", "summer"};
Exercise 1 – WordCount1
Implement WordCount1 by using a List (or array) to store each word and the number of occurrences.
Hint: Implement a Count class that stores a single word and its count. Instances of the Count class may then be stored by the List (or array).
____________________________________________________________
Exercise 2 – WordCount2
Implement WordCount2 by using a Map to store each word and the number of occurrences.
____________________________________________________________
Exercise 3 – TestWordCount
Implement a class TestWordCount which declares the exact String array given in the example above, and passes it as a parameter to the storeWords methods in the two WordCount classes. This class should call the storeWords method, passing the example array, then call the two print methods for the WordCount1 class. It should then do exactly the same for the WordCount2 class. Include printing indicating which output is for exercise 1 and 2.
While you may test with other input arrays, this class must be demonstrated and submitted with the example array given previously.
Now i understand that the array is declared in the TestWordCount class and then the method storeWords(String[] array) is meant to be called from each WordCount1 and WordCount2 which will sort through the array. I have no idea were to even begin!!! any help would be very very appreciated.
This project involves implementing two classes called WordCount1 and WordCount2 (for Exercises 1 and 2 respectively). Both classes may be created in the one project called WordCount. Both classes count the number of occurrences of each word or phrase from a given input array of Strings. Your classes should process the given input array to produce the information regarding the occurrence of each word (this will be done in storeWords() below). The following methods should be implemented in both classes:
1. storeWords(String[] array) which iterates through a given passed array storing unique words/phrases and the number of times they were found in the array. This method will be called from the test class outlined in Exercise 3.
2. printWords() which will print out all unique words and their number of occurrences. Words can be printed out in any order.
3. topFourWords() which will print out the four words that have the most number of occurrences. These words will be printed in descending order of occurrence.
Now the given array to be used is
private String[] array = {"ICT", "School", "2B", "pencil", "2B", "2B", "project", "quiz", "pencil", "2B", "quiz", "pencil", "quiz", "2B", "I", "programming", "student", "star", "apple", "queen", "such", "access", "JJJ", "student", "project", "star", "orange", "summer", "spring", "hello", "access", "pencil", "programming", "elbow", "apple", "quiz", "pear", "orange", "around the horn", "such is life", "access", "ICT", "winter", "summer"};
Exercise 1 – WordCount1
Implement WordCount1 by using a List (or array) to store each word and the number of occurrences.
Hint: Implement a Count class that stores a single word and its count. Instances of the Count class may then be stored by the List (or array).
____________________________________________________________
Exercise 2 – WordCount2
Implement WordCount2 by using a Map to store each word and the number of occurrences.
____________________________________________________________
Exercise 3 – TestWordCount
Implement a class TestWordCount which declares the exact String array given in the example above, and passes it as a parameter to the storeWords methods in the two WordCount classes. This class should call the storeWords method, passing the example array, then call the two print methods for the WordCount1 class. It should then do exactly the same for the WordCount2 class. Include printing indicating which output is for exercise 1 and 2.
While you may test with other input arrays, this class must be demonstrated and submitted with the example array given previously.
Now i understand that the array is declared in the TestWordCount class and then the method storeWords(String[] array) is meant to be called from each WordCount1 and WordCount2 which will sort through the array. I have no idea were to even begin!!! any help would be very very appreciated.