kleinere Änderungen
This commit is contained in:
parent
87b3b7108b
commit
f7417b8a3b
|
@ -39,12 +39,9 @@ public class Vorlesungsverzeichnis implements Comparator<Vorlesung>{
|
|||
* @return eine alphabetisch sortierte Liste mit den Titeln aller Vorlesungen.
|
||||
*/
|
||||
public List<String> titles() {
|
||||
Set<String> set = new HashSet<>();
|
||||
SortedSet<String> set = new TreeSet<>();
|
||||
vorlesungen.forEach(vorlesung -> set.add(vorlesung.getTitle()));
|
||||
|
||||
List<String> list = new ArrayList<>(set);
|
||||
Collections.sort(list);
|
||||
return list;
|
||||
return new ArrayList<>(set);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.joethei.hs.java2.tests;
|
||||
|
||||
import de.joethei.hs.java2.praktikum.praktikum3.TextFileFormatException;
|
||||
import de.joethei.hs.java2.praktikum.praktikum3.Vorlesung;
|
||||
import de.joethei.hs.java2.praktikum.praktikum3.Vorlesungsverzeichnis;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -116,4 +117,19 @@ public class VorlesungsverzeichnisTest {
|
|||
assertEquals(list, vorlesungsverzeichnis.descendingTitles());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toStringTest() {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("I2");
|
||||
list.add("Java 2");
|
||||
list.add("Rump");
|
||||
list.add("10");
|
||||
try {
|
||||
Vorlesung vorlesung = new Vorlesung(list);
|
||||
assertEquals(vorlesung.toString(), "I2:Java 2:Rump:10");
|
||||
} catch (TextFileFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -14,8 +14,8 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class VorlesungsverzeichnisTest2 {
|
||||
String filename = "src/main/resources/praktikum3/vorlesungen-db.txt";
|
||||
PrintWriter pw;
|
||||
private String filename = "src/main/resources/praktikum3/vorlesungen-db.txt";
|
||||
private PrintWriter pw;
|
||||
|
||||
Class<Vorlesung> c = Vorlesung.class; // Klasse Vorlesung vorhanden?
|
||||
|
||||
|
|
Loading…
Reference in New Issue