University stuff.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestOrdliste.java 905B

12345678910111213141516171819202122232425262728293031
  1. class TestOrdliste {
  2. public static void main(String[] args) {
  3. Ordliste liste = new Ordliste();
  4. String str = "foo foo bar foo hello bar bar bar how are you you you you";
  5. String[] strs = str.split("\\s+");
  6. for (String s: strs)
  7. liste.leggTilOrd(s);
  8. System.out.println("String:");
  9. System.out.println(str);
  10. System.out.println("");
  11. System.out.println("Number of words (should be 6):");
  12. System.out.println(liste.antallOrd());
  13. System.out.println("Most common word (should be 'bar'):");
  14. System.out.println(liste.vanligste().toString());
  15. System.out.println("");
  16. System.out.println("Most common words (should be 'bar' and 'you'):");
  17. for (Ord o: liste.alleVanligste())
  18. System.out.println(o.toString());
  19. System.out.println("");
  20. System.out.println("Occurrences of 'bar' (should be 4):");
  21. System.out.println(liste.antallForekomster("bar"));
  22. System.out.println("");
  23. }
  24. }