Hallo, ich bin neu hier und bräuchte Hilfe für meine Hausaufgabe im Studium.
Das oben ist mein Code wobei die Antwort dann vom Prof kam:
viel einfacher ist es in readAndStoreTags, nicht das gesamte tag_map in einer Schleife durchzugehen, sondern nur gezielt tag_map.get("title") usw. zu holen.
gesagt und getan hab ich das umgeschrieben in das:
jedoch kommen jetzt andere Fehler auf
wär cool wenn mir einer helfen könnte
Java:
public void readAndStoreTags() {
Map<String, Object> tag_map = TagReader.readTags(getPathname());
for(String key: tag_map.keySet()) {
if(key.equals("author") && (tag_map.get(key)!=null)) author = ((String) tag_map.get(key)).trim();
if(key.equals("album") && (tag_map.get(key)!=null)) album = ((String) tag_map.get(key)).trim();
if(key.equals("duration") && (tag_map.get(key)!=null)) {
duration = (long) tag_map.get(key);
}
if(key.equals("title") && (tag_map.get(key)!=null)) title = ((String) tag_map.get(key)).trim();
}
}
Das oben ist mein Code wobei die Antwort dann vom Prof kam:
viel einfacher ist es in readAndStoreTags, nicht das gesamte tag_map in einer Schleife durchzugehen, sondern nur gezielt tag_map.get("title") usw. zu holen.
gesagt und getan hab ich das umgeschrieben in das:
Java:
public void readAndStoreTags(String pathname) {
Map<String, Object> tag_map = TagReader.readTags(pathname);
System.out.println(tag_map.get("title"));
if (tag_map.get("title") != null) {
super.title = ((String) tag_map.get("title")).trim();
}
if (tag_map.get("author") != null) {
super.author = ((String) tag_map.get("author")).trim();
}
if (tag_map.get("album") != null) {
this.album = ((String) tag_map.get("album")).trim();
}
if (tag_map.get("duration") != null) {
this.duration = (long) tag_map.get("duration");
}
}
jedoch kommen jetzt andere Fehler auf
wär cool wenn mir einer helfen könnte
Zuletzt bearbeitet: