Praktikum 3: kleine Änderungen
This commit is contained in:
parent
2612ab664d
commit
90a5f6f6d1
|
@ -0,0 +1,10 @@
|
|||
package de.joethei.hs.java2.praktikum.praktikum3;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TextFileFormatException extends IOException {
|
||||
|
||||
public TextFileFormatException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package de.joethei.hs.java2.praktikum.praktikum3;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TextFormatException extends IOException {
|
||||
|
||||
public TextFormatException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
|
@ -6,14 +6,14 @@ public class Vorlesung {
|
|||
private String studiengruppe;
|
||||
private String title;
|
||||
private String dozent;
|
||||
private String teilnehmerzahl;
|
||||
private int teilnehmerzahl;
|
||||
|
||||
public Vorlesung(List<String> list) throws TextFormatException{
|
||||
if(list.size() <1 || list.size() > 4) throw new TextFormatException("invalid number of Strings in list");
|
||||
public Vorlesung(List<String> list) throws TextFileFormatException {
|
||||
if(list.size() <1 || list.size() > 4) throw new TextFileFormatException("invalid number of Strings in list");
|
||||
this.studiengruppe = list.get(0);
|
||||
this.title = list.get(1);
|
||||
this.dozent = list.get(2);
|
||||
this.teilnehmerzahl = list.get(3);
|
||||
this.teilnehmerzahl = Integer.parseInt(list.get(3));
|
||||
}
|
||||
|
||||
public String getStudiengruppe() {
|
||||
|
@ -28,7 +28,7 @@ public class Vorlesung {
|
|||
return dozent;
|
||||
}
|
||||
|
||||
public String getTeilnehmerzahl() {
|
||||
public int getTeilnehmerzahl() {
|
||||
return teilnehmerzahl;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,11 @@ public class Vorlesungsverzeichnis {
|
|||
List<List<String>> datenbasis;
|
||||
datenbasis = load(filename);
|
||||
for(List<String> a : datenbasis) {
|
||||
if(a.size() != 4) throw new TextFormatException("unexpected number of Strings in line");
|
||||
if(a.size() != 4) throw new TextFileFormatException("unexpected number of Strings in line");
|
||||
for(String s : a) if(s.isEmpty()) throw new TextFileFormatException("empty attribute");
|
||||
|
||||
|
||||
|
||||
vorlesungen.add(new Vorlesung(a));
|
||||
}
|
||||
}
|
||||
|
@ -96,8 +100,8 @@ public class Vorlesungsverzeichnis {
|
|||
int most=0, index=0;
|
||||
while(vl.size()>0) {
|
||||
for(int i=0; i<vl.size(); i++) {
|
||||
if(Integer.parseInt(vl.get(i).getTeilnehmerzahl())>=most) {
|
||||
most = Integer.parseInt(vl.get(i).getTeilnehmerzahl());
|
||||
if(vl.get(i).getTeilnehmerzahl()>=most) {
|
||||
most = vl.get(i).getTeilnehmerzahl();
|
||||
index=i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,8 +81,8 @@ public class VorlesungsverzeichnisTest {
|
|||
Map<String, List<String>> map = vorlesungsverzeichnis.multipleTitles();
|
||||
|
||||
List<String> math = new ArrayList<>();
|
||||
math.add("von Coelln");
|
||||
math.add("Rabe");
|
||||
math.add("von Coelln");
|
||||
|
||||
assertEquals(map.get("Mathematik 2"), math);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue