12345678910111213141516171819202122232425262728293031 |
- class TestOrdliste {
- public static void main(String[] args) {
- Ordliste liste = new Ordliste();
-
- String str = "foo foo bar foo hello bar bar bar how are you you you you";
- String[] strs = str.split("\\s+");
-
- for (String s: strs)
- liste.leggTilOrd(s);
-
- System.out.println("String:");
- System.out.println(str);
- System.out.println("");
-
- System.out.println("Number of words (should be 6):");
- System.out.println(liste.antallOrd());
-
- System.out.println("Most common word (should be 'bar'):");
- System.out.println(liste.vanligste().toString());
- System.out.println("");
-
- System.out.println("Most common words (should be 'bar' and 'you'):");
- for (Ord o: liste.alleVanligste())
- System.out.println(o.toString());
- System.out.println("");
-
- System.out.println("Occurrences of 'bar' (should be 4):");
- System.out.println(liste.antallForekomster("bar"));
- System.out.println("");
- }
- }
|