diff --git a/Bibliotheksverwaltungssystem/ki-ChatGPT/Prompt3.txt b/Bibliotheksverwaltungssystem/ki-ChatGPT/Prompt3.txt new file mode 100644 index 0000000..8c98a7f --- /dev/null +++ b/Bibliotheksverwaltungssystem/ki-ChatGPT/Prompt3.txt @@ -0,0 +1,54 @@ +public ArrayList medienart(String medienart, HashMap medien) { + switch(medienart) { + case "Bücher": + return medien.entrySet().stream() + .filter(t -> t.getValue().getMedium() instanceof Buch) + .map(t -> t.getValue().getMedium()) + .map(t -> ((Buch)t)) + .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); + + case "Brettspiele": + return medien.entrySet().stream() + .filter(t -> t.getValue().getMedium() instanceof Brettspiel) + .map(t -> t.getValue().getMedium()) + .map(t -> ((Brettspiel)t)) + .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); + + case "Dvds": + return medien.entrySet().stream() + .filter(t -> t.getValue().getMedium() instanceof Dvd) + .map(t -> t.getValue().getMedium()) + .map(t -> ((Dvd)t)) + .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); + + case "Cds": + return medien.entrySet().stream() + .filter(t -> t.getValue().getMedium() instanceof Cd) + .map(t -> t.getValue().getMedium()) + .map(t -> ((Cd)t)) + .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); + + case "Videospiele": + return medien.entrySet().stream() + .filter(t -> t.getValue().getMedium() instanceof Videospiel) + .map(t -> t.getValue().getMedium()) + .map(t -> ((Videospiel)t)) + .map(t -> "Eindutige Kennung= " + t.toString()) + .collect(Collectors.toCollection(ArrayList::new)); + + default: + return null; + + } + + } + + +kann man das Code igrendwoie zusammenfassung?? + + +Antwort: +a, dein Code kann stark vereinfacht und zusammengefasst werden, indem du redundante Codeblöcke vermeidest. Alle case-Blöcke folgen demselben Muster. Du kannst die Class-Objekte (wie Buch.class, Brettspiel.class, etc.) als Parameter verwenden, um den Vergleich dynamisch zu gestalten. + +Hier ist die überarbeitete und zusammengefasste Version: +Zusammenfassung des Codes \ No newline at end of file diff --git a/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/AusleiheJTest.java b/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/AusleiheJTest.java deleted file mode 100644 index 75b4ab3..0000000 --- a/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/AusleiheJTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package domain.AusleiheSystem; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import domain.fassade.BibSystem; - -class AusleiheJTest { - - private BibSystem bib; - - @BeforeEach - void setUp() throws Exception { - this.bib = new BibSystem(); - } - - @Test - void test() throws Exception { - bib.userRegistrieren("obai", "student", 15, "nein"); - bib.userAnmelden("K1000"); - bib.mediumAusleihen("K1000", "B001"); - } - -} diff --git a/Bibliotheksverwaltungssystem/src/domain/Benutzer/Studenten.java b/Bibliotheksverwaltungssystem/src/domain/Benutzer/Studenten.java deleted file mode 100644 index bd962ae..0000000 --- a/Bibliotheksverwaltungssystem/src/domain/Benutzer/Studenten.java +++ /dev/null @@ -1,14 +0,0 @@ -package domain.Benutzer; - -public class Studenten extends Benutzer { - - public Studenten(Ausweis bibAusweis, String name, int alter, boolean istStudent) { - super(bibAusweis, name, alter, istStudent); - } - - @Override - public double getJahresgebühren() { - return 25.0; - } - -} diff --git a/Bibliotheksverwaltungssystem/src/domain/Bibliothekskatalog/Mediensuchen.java b/Bibliotheksverwaltungssystem/src/domain/Bibliothekskatalog/Mediensuchen.java deleted file mode 100644 index 5c683ba..0000000 --- a/Bibliotheksverwaltungssystem/src/domain/Bibliothekskatalog/Mediensuchen.java +++ /dev/null @@ -1,88 +0,0 @@ -package domain.Bibliothekskatalog; - -import java.time.LocalDate; -import java.time.temporal.ChronoUnit; -import java.util.*; -import java.util.stream.Collectors; - -import domain.AusleiheSystem.Ausleihe; -import domain.Medium.*; - -public class Mediensuchen { - - public ArrayList title(String title, HashMap medien) { - return medien.entrySet().stream() - .filter(t -> t.getValue().getMedium().getTitle().equalsIgnoreCase(title)) - .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); - } - - public ArrayList ausgeliehen(String ausgeliehen, HashMap medien) { - return medien.entrySet().stream() - .filter(t -> t.getValue().isIstAusgeliehen()) - .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); - } - - public ArrayList nichtAusgeliehen(String ausgeliehen, HashMap medien) { - return medien.entrySet().stream() - .filter(t -> !(t.getValue().isIstAusgeliehen())) - .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); - } - - - public ArrayList medienart(String medienart, HashMap medien) { - switch(medienart) { - case "Bücher": - return medien.entrySet().stream() - .filter(t -> t.getValue().getMedium() instanceof Buch) - .map(t -> t.getValue().getMedium()) - .map(t -> ((Buch)t)) - .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); - - case "Brettspiele": - return medien.entrySet().stream() - .filter(t -> t.getValue().getMedium() instanceof Brettspiel) - .map(t -> t.getValue().getMedium()) - .map(t -> ((Brettspiel)t)) - .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); - - case "Dvds": - return medien.entrySet().stream() - .filter(t -> t.getValue().getMedium() instanceof Dvd) - .map(t -> t.getValue().getMedium()) - .map(t -> ((Dvd)t)) - .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); - - case "Cds": - return medien.entrySet().stream() - .filter(t -> t.getValue().getMedium() instanceof Cd) - .map(t -> t.getValue().getMedium()) - .map(t -> ((Cd)t)) - .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); - - case "Videospiele": - return medien.entrySet().stream() - .filter(t -> t.getValue().getMedium() instanceof Videospiel) - .map(t -> t.getValue().getMedium()) - .map(t -> ((Videospiel)t)) - .map(t -> "Eindutige Kennung= " + t.toString()) - .collect(Collectors.toCollection(ArrayList::new)); - - default: - return null; - - } - - } - - public ArrayList baldVerfügbareMedien(ArrayList ausleihe) { - LocalDate heutigesDatum = LocalDate.now(); - - return ausleihe.stream() - .filter(t -> t.getAusleiheEnde().until(heutigesDatum, ChronoUnit.DAYS) <= 3) - .map(t -> t.getMediumverwalter()) - .map(t -> t.toString()) - .collect(Collectors.toCollection(ArrayList::new)); - - } - -} diff --git a/Bibliotheksverwaltungssystem/src/domain/Testate/AusleihenTest.java b/Bibliotheksverwaltungssystem/src/domain/Testate/AusleihenTest.java deleted file mode 100644 index fac4d3d..0000000 --- a/Bibliotheksverwaltungssystem/src/domain/Testate/AusleihenTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package domain.Testate; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import domain.fassade.BibSystem; - -class AusleihenTest { - - private BibSystem bib; - - @BeforeEach - void setUp() throws Exception { - this.bib = new BibSystem(); - } - - @Disabled - void testAusleiheFris() throws Exception { - - bib.userRegistrieren("obai", "student", 15, "nein"); - bib.userAnmelden("K1001"); - double gerbühren = bib.mediumAusleihen("K1001", "B001"); - assertEquals(0.0,gerbühren); - - // das ist ein Test für das Testate: - String ausleihBeginn = "2024-11-01"; - String ausleihEnde = "2024-12-01"; - String heutigesDatum = "2024-12-05"; - double überfälligeGebühren = bib.datumÄndern("B001", ausleihBeginn, ausleihEnde, heutigesDatum); - assertEquals(4.0,überfälligeGebühren); - - // Gebühren bezahlen (Admin) - assertTrue(bib.adminAnmelden("A1000")); - assertEquals(4.0,bib.getgbührenBenutzer("K1001")); - assertTrue(bib.gebührenVerbuchen("K1001")); - } - - @Test - void testMitJahresGebühren() throws Exception { - - bib.userRegistrieren("obai", "student", 15, "nein"); - bib.userAnmelden("K1001"); - double gerbühren = bib.mediumAusleihen("K1001", "B001"); - assertEquals(0.0,gerbühren); - - // das ist eine Test für das Testate: - String ausleihBeginn = "2024-11-01"; - String ausleihEnde = "2024-12-01"; - String heutigesDatum = "2024-12-05"; - double überfälligeGebühren = bib.datumÄndern("B001", ausleihBeginn, ausleihEnde, heutigesDatum); - assertEquals(4.0,überfälligeGebühren); - - // setze noch jahresGebühren dazu - double jahreGebühren = bib.jahresGebührenBerechnen("K1001", "2025-11-19"); - assertEquals(29.0,jahreGebühren); - - // Gebühren bezahlen (Admin) - assertTrue(bib.adminAnmelden("A1000")); - assertEquals(29.0,bib.getgbührenBenutzer("K1001")); - assertTrue(bib.gebührenVerbuchen("K1001")); - } - -} diff --git a/Bibliotheksverwaltungssystem/src/domain/Testate/RegistrierenTest.java b/Bibliotheksverwaltungssystem/src/domain/Testate/RegistrierenTest.java deleted file mode 100644 index 12daa43..0000000 --- a/Bibliotheksverwaltungssystem/src/domain/Testate/RegistrierenTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package domain.Testate; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -import domain.Benutzer.*; -import domain.ExceptionsKlassen.FalscheEingabeException; -import domain.UserRegistieren.Registieren; - -class RegistrierenTest { - - @Test - void testKunde() throws FalscheEingabeException { - - Benutzer student = Registieren.userRegistrieren("Müller", "student", 15, "nein"); - // True - assertTrue(student instanceof Studenten); - - Benutzer erwachsener = Registieren.userRegistrieren("Schneider", "erwachsener", 15, "nein"); - // True - assertTrue(erwachsener instanceof Erwachsener); - - Benutzer mitarbeiter = Registieren.userRegistrieren("Schuchmacher", "mitarbeiter", 15, "ja"); - assertTrue(mitarbeiter instanceof Mitarbeiter); - - } - -} diff --git a/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/Ausleihe.java b/Bibliotheksverwaltungssystem/src/domain/ausleihSystem/Ausleihe.java similarity index 93% rename from Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/Ausleihe.java rename to Bibliotheksverwaltungssystem/src/domain/ausleihSystem/Ausleihe.java index cf07307..dd37815 100644 --- a/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/Ausleihe.java +++ b/Bibliotheksverwaltungssystem/src/domain/ausleihSystem/Ausleihe.java @@ -1,10 +1,10 @@ -package domain.AusleiheSystem; +package domain.ausleihSystem; import java.time.LocalDate; import java.util.Date; -import domain.Benutzer.Benutzer; -import domain.Medium.Mediumverwalter; +import domain.benutzer.Benutzer; +import domain.medium.Mediumverwalter; public class Ausleihe { diff --git a/Bibliotheksverwaltungssystem/src/domain/Testate/MediumsVerlängernTest.java b/Bibliotheksverwaltungssystem/src/domain/ausleihSystem/AusleiheJTest.java similarity index 72% rename from Bibliotheksverwaltungssystem/src/domain/Testate/MediumsVerlängernTest.java rename to Bibliotheksverwaltungssystem/src/domain/ausleihSystem/AusleiheJTest.java index edecb13..88cec59 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Testate/MediumsVerlängernTest.java +++ b/Bibliotheksverwaltungssystem/src/domain/ausleihSystem/AusleiheJTest.java @@ -1,4 +1,4 @@ -package domain.Testate; +package domain.ausleihSystem; import static org.junit.jupiter.api.Assertions.*; @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test; import domain.fassade.BibSystem; -class MediumsVerlängernTest { +class AusleiheJTest { private BibSystem bib; @@ -20,8 +20,9 @@ class MediumsVerlängernTest { void test() throws Exception { bib.userRegistrieren("obai", "student", 15, "nein"); bib.userAnmelden("K1001"); - bib.mediumAusleihen("K1001", "B001"); - assertTrue(bib.medienVerlängern("B001", "K1001")); + double userGebühren = bib.mediumAusleihen("K1001", "B001"); + assertEquals(0.0,userGebühren); + } } diff --git a/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/AusleiheProzess.png b/Bibliotheksverwaltungssystem/src/domain/ausleihSystem/AusleiheProzess.png similarity index 100% rename from Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/AusleiheProzess.png rename to Bibliotheksverwaltungssystem/src/domain/ausleihSystem/AusleiheProzess.png diff --git a/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/AusleiheSystem.java b/Bibliotheksverwaltungssystem/src/domain/ausleihSystem/AusleiheSystem.java similarity index 96% rename from Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/AusleiheSystem.java rename to Bibliotheksverwaltungssystem/src/domain/ausleihSystem/AusleiheSystem.java index 404dc73..727bc22 100644 --- a/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/AusleiheSystem.java +++ b/Bibliotheksverwaltungssystem/src/domain/ausleihSystem/AusleiheSystem.java @@ -1,12 +1,12 @@ -package domain.AusleiheSystem; +package domain.ausleihSystem; import java.time.LocalDate; import java.time.temporal.ChronoUnit; import java.util.*; -import domain.Benutzer.Benutzer; -import domain.ExceptionsKlassen.MediumNichtGefundenException; -import domain.Medium.*; +import domain.benutzer.Benutzer; +import domain.exceptionsKlassen.MediumNichtGefundenException; +import domain.medium.*; public class AusleiheSystem { diff --git a/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/MedienRückgabeTest.java b/Bibliotheksverwaltungssystem/src/domain/ausleihSystem/MedienRückgabeTest.java similarity index 93% rename from Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/MedienRückgabeTest.java rename to Bibliotheksverwaltungssystem/src/domain/ausleihSystem/MedienRückgabeTest.java index 5e45e3d..e850c3e 100644 --- a/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/MedienRückgabeTest.java +++ b/Bibliotheksverwaltungssystem/src/domain/ausleihSystem/MedienRückgabeTest.java @@ -1,4 +1,4 @@ -package domain.AusleiheSystem; +package domain.ausleihSystem; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -9,7 +9,7 @@ import java.util.ArrayList; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import domain.Benutzer.Benutzer; +import domain.benutzer.Benutzer; import domain.fassade.BibSystem; class MedienRückgabeTest { diff --git a/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/MediumVerlängernTest.java b/Bibliotheksverwaltungssystem/src/domain/ausleihSystem/MediumVerlängernTest.java similarity index 94% rename from Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/MediumVerlängernTest.java rename to Bibliotheksverwaltungssystem/src/domain/ausleihSystem/MediumVerlängernTest.java index e68e364..3b26f24 100644 --- a/Bibliotheksverwaltungssystem/src/domain/AusleiheSystem/MediumVerlängernTest.java +++ b/Bibliotheksverwaltungssystem/src/domain/ausleihSystem/MediumVerlängernTest.java @@ -1,4 +1,4 @@ -package domain.AusleiheSystem; +package domain.ausleihSystem; import static org.junit.jupiter.api.Assertions.*; diff --git a/Bibliotheksverwaltungssystem/src/domain/Benutzer/Ausweis.java b/Bibliotheksverwaltungssystem/src/domain/benutzer/Ausweis.java similarity index 91% rename from Bibliotheksverwaltungssystem/src/domain/Benutzer/Ausweis.java rename to Bibliotheksverwaltungssystem/src/domain/benutzer/Ausweis.java index fba17e5..21f831f 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Benutzer/Ausweis.java +++ b/Bibliotheksverwaltungssystem/src/domain/benutzer/Ausweis.java @@ -1,4 +1,4 @@ -package domain.Benutzer; +package domain.benutzer; public class Ausweis { private String kartennummer; diff --git a/Bibliotheksverwaltungssystem/src/domain/Benutzer/Benutzer.java b/Bibliotheksverwaltungssystem/src/domain/benutzer/Benutzer.java similarity index 98% rename from Bibliotheksverwaltungssystem/src/domain/Benutzer/Benutzer.java rename to Bibliotheksverwaltungssystem/src/domain/benutzer/Benutzer.java index 96235a9..d986fba 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Benutzer/Benutzer.java +++ b/Bibliotheksverwaltungssystem/src/domain/benutzer/Benutzer.java @@ -1,8 +1,9 @@ -package domain.Benutzer; +package domain.benutzer; import java.time.LocalDate; import java.util.ArrayList; -import domain.AusleiheSystem.Ausleihe; + +import domain.ausleihSystem.Ausleihe; public abstract class Benutzer { diff --git a/Bibliotheksverwaltungssystem/src/domain/Benutzer/Erwachsener.java b/Bibliotheksverwaltungssystem/src/domain/benutzer/Erwachsener.java similarity index 90% rename from Bibliotheksverwaltungssystem/src/domain/Benutzer/Erwachsener.java rename to Bibliotheksverwaltungssystem/src/domain/benutzer/Erwachsener.java index 093d634..79f2a7e 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Benutzer/Erwachsener.java +++ b/Bibliotheksverwaltungssystem/src/domain/benutzer/Erwachsener.java @@ -1,4 +1,4 @@ -package domain.Benutzer; +package domain.benutzer; public class Erwachsener extends Benutzer { diff --git a/Bibliotheksverwaltungssystem/src/domain/Benutzer/Mitarbeiter.java b/Bibliotheksverwaltungssystem/src/domain/benutzer/Mitarbeiter.java similarity index 93% rename from Bibliotheksverwaltungssystem/src/domain/Benutzer/Mitarbeiter.java rename to Bibliotheksverwaltungssystem/src/domain/benutzer/Mitarbeiter.java index dff42cd..4c28315 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Benutzer/Mitarbeiter.java +++ b/Bibliotheksverwaltungssystem/src/domain/benutzer/Mitarbeiter.java @@ -1,4 +1,4 @@ -package domain.Benutzer; +package domain.benutzer; public class Mitarbeiter extends Benutzer { diff --git a/Bibliotheksverwaltungssystem/src/domain/benutzer/Student.java b/Bibliotheksverwaltungssystem/src/domain/benutzer/Student.java new file mode 100644 index 0000000..1307b3d --- /dev/null +++ b/Bibliotheksverwaltungssystem/src/domain/benutzer/Student.java @@ -0,0 +1,14 @@ +package domain.benutzer; + +public class Student extends Benutzer { + + public Student(Ausweis bibAusweis, String name, int alter, boolean istStudent) { + super(bibAusweis, name, alter, istStudent); + } + + @Override + public double getJahresgebühren() { + return 25.0; + } + +} diff --git a/Bibliotheksverwaltungssystem/src/domain/Bibliothekskatalog/MedienSuchenTest.java b/Bibliotheksverwaltungssystem/src/domain/bibliothekskatalog/MedienSuchenTest.java similarity index 80% rename from Bibliotheksverwaltungssystem/src/domain/Bibliothekskatalog/MedienSuchenTest.java rename to Bibliotheksverwaltungssystem/src/domain/bibliothekskatalog/MedienSuchenTest.java index f2c7fe4..8eb7776 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Bibliothekskatalog/MedienSuchenTest.java +++ b/Bibliotheksverwaltungssystem/src/domain/bibliothekskatalog/MedienSuchenTest.java @@ -1,4 +1,4 @@ -package domain.Bibliothekskatalog; +package domain.bibliothekskatalog; import static org.junit.jupiter.api.Assertions.*; @@ -8,13 +8,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import domain.Benutzer.Benutzer; -import domain.ExceptionsKlassen.BenutzerNichtAngemeldetException; -import domain.ExceptionsKlassen.BenutzerNichtGefundenException; -import domain.ExceptionsKlassen.FalscheEingabeException; -import domain.ExceptionsKlassen.MediumNichtGefundenException; -import domain.UserRegistieren.Registieren; +import domain.benutzer.Benutzer; +import domain.exceptionsKlassen.BenutzerNichtAngemeldetException; +import domain.exceptionsKlassen.BenutzerNichtGefundenException; +import domain.exceptionsKlassen.FalscheEingabeException; +import domain.exceptionsKlassen.MediumNichtGefundenException; import domain.fassade.BibSystem; +import domain.fassade.Registieren; class MedienSuchenTest { @@ -35,14 +35,14 @@ private BibSystem fassade; } - @Disabled + @Test void testMedienSuchenNachMedienart()throws MediumNichtGefundenException, FalscheEingabeException, BenutzerNichtAngemeldetException, BenutzerNichtGefundenException { ArrayList nichtAusgeliehen = fassade.mediumDurchsuchen("Videospiele", "K1001"); nichtAusgeliehen.forEach(System.out::println); } - @Test + @Disabled void testMedienSuchenNachausgeliehen()throws MediumNichtGefundenException, FalscheEingabeException, BenutzerNichtAngemeldetException, BenutzerNichtGefundenException { ArrayList nichtAusgeliehen = fassade.mediumDurchsuchen("ausgeliehen", "K1001"); nichtAusgeliehen.forEach(System.out::println); diff --git a/Bibliotheksverwaltungssystem/src/domain/bibliothekskatalog/Mediensuchen.java b/Bibliotheksverwaltungssystem/src/domain/bibliothekskatalog/Mediensuchen.java new file mode 100644 index 0000000..6ad245a --- /dev/null +++ b/Bibliotheksverwaltungssystem/src/domain/bibliothekskatalog/Mediensuchen.java @@ -0,0 +1,69 @@ +package domain.bibliothekskatalog; + +import java.time.LocalDate; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.stream.Collectors; + +import domain.ausleihSystem.Ausleihe; +import domain.medium.*; + +public class Mediensuchen { + + public ArrayList title(String title, HashMap medien) { + return medien.entrySet().stream() + .filter(t -> t.getValue().getMedium().getTitle().equalsIgnoreCase(title)) + .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); + } + + public ArrayList ausgeliehen(String ausgeliehen, HashMap medien) { + return medien.entrySet().stream() + .filter(t -> t.getValue().isIstAusgeliehen()) + .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); + } + + public ArrayList nichtAusgeliehen(String ausgeliehen, HashMap medien) { + return medien.entrySet().stream() + .filter(t -> !(t.getValue().isIstAusgeliehen())) + .map(t -> "Eindutige Kennung= " + t.toString()).collect(Collectors.toCollection(ArrayList::new)); + } + + + public ArrayList medienart(String medienart, HashMap medien) { + // Map zur Zuordnung von medienart zu Klassen + Map> medienKlassen = Map.of( + "Bücher", Buch.class, + "Brettspiele", Brettspiel.class, + "Dvds", Dvd.class, + "Cds", Cd.class, + "Videospiele", Videospiel.class + ); + + // Ermitteln der entsprechenden Klasse für die angegebene Medienart + Class klasse = medienKlassen.get(medienart); + + if (klasse == null) { + return null; // Ungültige Medienart + } + + // Stream für die Filterung und Konvertierung + return medien.entrySet().stream() + .filter(t -> klasse.isInstance(t.getValue().getMedium())) // Filtert nach der Klasse + .map(t -> klasse.cast(t.getValue().getMedium())) // Castet das Medium zur richtigen Klasse + .map(t -> "Eindutige Kennung= " + t.toString()) // Konvertiert zu String + .collect(Collectors.toCollection(ArrayList::new)); // Sammeln als ArrayList + } + + + public ArrayList baldVerfügbareMedien(ArrayList ausleihe) { + LocalDate heutigesDatum = LocalDate.now(); + + return ausleihe.stream() + .filter(t -> t.getAusleiheEnde().until(heutigesDatum, ChronoUnit.DAYS) <= 3) + .map(t -> t.getMediumverwalter()) + .map(t -> t.toString()) + .collect(Collectors.toCollection(ArrayList::new)); + + } + +} diff --git a/Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/BenutzerNichtAngemeldetException.java b/Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/BenutzerNichtAngemeldetException.java similarity index 81% rename from Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/BenutzerNichtAngemeldetException.java rename to Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/BenutzerNichtAngemeldetException.java index b8c39f6..7f485ba 100644 --- a/Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/BenutzerNichtAngemeldetException.java +++ b/Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/BenutzerNichtAngemeldetException.java @@ -1,4 +1,4 @@ -package domain.ExceptionsKlassen; +package domain.exceptionsKlassen; public class BenutzerNichtAngemeldetException extends Exception { diff --git a/Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/BenutzerNichtGefundenException.java b/Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/BenutzerNichtGefundenException.java similarity index 80% rename from Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/BenutzerNichtGefundenException.java rename to Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/BenutzerNichtGefundenException.java index 00d9657..b38b789 100644 --- a/Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/BenutzerNichtGefundenException.java +++ b/Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/BenutzerNichtGefundenException.java @@ -1,4 +1,4 @@ -package domain.ExceptionsKlassen; +package domain.exceptionsKlassen; public class BenutzerNichtGefundenException extends Exception { diff --git a/Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/FalscheEingabeException.java b/Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/FalscheEingabeException.java similarity index 79% rename from Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/FalscheEingabeException.java rename to Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/FalscheEingabeException.java index 6c0b3cc..31787ad 100644 --- a/Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/FalscheEingabeException.java +++ b/Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/FalscheEingabeException.java @@ -1,4 +1,4 @@ -package domain.ExceptionsKlassen; +package domain.exceptionsKlassen; public class FalscheEingabeException extends Exception { diff --git a/Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/MediumNichtGefundenException.java b/Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/MediumNichtGefundenException.java similarity index 80% rename from Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/MediumNichtGefundenException.java rename to Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/MediumNichtGefundenException.java index b9f89b1..954d2be 100644 --- a/Bibliotheksverwaltungssystem/src/domain/ExceptionsKlassen/MediumNichtGefundenException.java +++ b/Bibliotheksverwaltungssystem/src/domain/exceptionsKlassen/MediumNichtGefundenException.java @@ -1,4 +1,4 @@ -package domain.ExceptionsKlassen; +package domain.exceptionsKlassen; public class MediumNichtGefundenException extends Exception { diff --git a/Bibliotheksverwaltungssystem/src/domain/fassade/BibSystem.java b/Bibliotheksverwaltungssystem/src/domain/fassade/BibSystem.java index 52976de..03f912a 100644 --- a/Bibliotheksverwaltungssystem/src/domain/fassade/BibSystem.java +++ b/Bibliotheksverwaltungssystem/src/domain/fassade/BibSystem.java @@ -1,12 +1,12 @@ package domain.fassade; import java.util.*; -import domain.AusleiheSystem.*; -import domain.Benutzer.*; -import domain.Bibliothekskatalog.Mediensuchen; -import domain.ExceptionsKlassen.*; -import domain.Medium.*; -import domain.UserRegistieren.Registieren; + +import domain.ausleihSystem.*; +import domain.benutzer.*; +import domain.bibliothekskatalog.Mediensuchen; +import domain.exceptionsKlassen.*; +import domain.medium.*; public class BibSystem { private ArrayList alleBibBenutzer; @@ -215,7 +215,7 @@ public class BibSystem { Mediumverwalter buchIStNichtAusgeliehen = new Mediumverwalter(new Buch("BG001", "Javascript lenren", 2018, "Joshua Bloch"),true, 10, 28); medien.put(buchIStNichtAusgeliehen.getMedium().getID(), buchIStNichtAusgeliehen); - Mediumverwalter Videospiel = new Mediumverwalter(new Videospiel("BG00122", "The Legend of Zelda: Breath of the Wild", 2017, "Nintendo Switch"),true, 2, 28); + Mediumverwalter Videospiel = new Mediumverwalter(new Videospiel("BG00122", "The Legend of Zelda: Breath of the Wild", 2017, "Nintendo Switch"),false, 2, 28); medien.put(Videospiel.getMedium().getID(), Videospiel); } diff --git a/Bibliotheksverwaltungssystem/src/domain/fassade/GebührenTest.java b/Bibliotheksverwaltungssystem/src/domain/fassade/GebührenTest.java index 4826d96..107234e 100644 --- a/Bibliotheksverwaltungssystem/src/domain/fassade/GebührenTest.java +++ b/Bibliotheksverwaltungssystem/src/domain/fassade/GebührenTest.java @@ -6,9 +6,9 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import domain.Benutzer.Benutzer; -import domain.ExceptionsKlassen.BenutzerNichtGefundenException; -import domain.ExceptionsKlassen.FalscheEingabeException; +import domain.benutzer.Benutzer; +import domain.exceptionsKlassen.BenutzerNichtGefundenException; +import domain.exceptionsKlassen.FalscheEingabeException; class GebührenTest { diff --git a/Bibliotheksverwaltungssystem/src/domain/UserRegistieren/Registieren.java b/Bibliotheksverwaltungssystem/src/domain/fassade/Registieren.java similarity index 83% rename from Bibliotheksverwaltungssystem/src/domain/UserRegistieren/Registieren.java rename to Bibliotheksverwaltungssystem/src/domain/fassade/Registieren.java index 69f2779..a7987e0 100644 --- a/Bibliotheksverwaltungssystem/src/domain/UserRegistieren/Registieren.java +++ b/Bibliotheksverwaltungssystem/src/domain/fassade/Registieren.java @@ -1,7 +1,7 @@ -package domain.UserRegistieren; +package domain.fassade; -import domain.Benutzer.*; -import domain.ExceptionsKlassen.FalscheEingabeException; +import domain.benutzer.*; +import domain.exceptionsKlassen.FalscheEingabeException; public class Registieren { @@ -14,7 +14,7 @@ public class Registieren { boolean admin = (istAdmin.equalsIgnoreCase("Ja"))? true : false; if ((type.equalsIgnoreCase("schüler") || type.equalsIgnoreCase("student"))) { ausweis = new Ausweis("K"); - benutzer = new Studenten(ausweis,name,alter,admin); + benutzer = new Student(ausweis,name,alter,admin); } else if (type.equalsIgnoreCase("erwachsener")) { ausweis = new Ausweis("K"); diff --git a/Bibliotheksverwaltungssystem/src/domain/UserRegistieren/RegistierenProzess.png b/Bibliotheksverwaltungssystem/src/domain/fassade/RegistierenProzess.png similarity index 100% rename from Bibliotheksverwaltungssystem/src/domain/UserRegistieren/RegistierenProzess.png rename to Bibliotheksverwaltungssystem/src/domain/fassade/RegistierenProzess.png diff --git a/Bibliotheksverwaltungssystem/src/domain/UserRegistieren/RegistrierenTest.java b/Bibliotheksverwaltungssystem/src/domain/fassade/RegistrierenTest.java similarity index 70% rename from Bibliotheksverwaltungssystem/src/domain/UserRegistieren/RegistrierenTest.java rename to Bibliotheksverwaltungssystem/src/domain/fassade/RegistrierenTest.java index 0cfc01a..439da7d 100644 --- a/Bibliotheksverwaltungssystem/src/domain/UserRegistieren/RegistrierenTest.java +++ b/Bibliotheksverwaltungssystem/src/domain/fassade/RegistrierenTest.java @@ -1,4 +1,4 @@ -package domain.UserRegistieren; +package domain.fassade; import static org.junit.jupiter.api.Assertions.*; @@ -6,12 +6,11 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import domain.Benutzer.Benutzer; -import domain.Benutzer.Erwachsener; -import domain.Benutzer.Mitarbeiter; -import domain.Benutzer.Studenten; -import domain.ExceptionsKlassen.FalscheEingabeException; -import domain.fassade.BibSystem; +import domain.benutzer.Benutzer; +import domain.benutzer.Erwachsener; +import domain.benutzer.Mitarbeiter; +import domain.benutzer.Student; +import domain.exceptionsKlassen.FalscheEingabeException; class RegistrierenTest { private BibSystem bib; @@ -26,7 +25,7 @@ class RegistrierenTest { Benutzer benutzer = Registieren.userRegistrieren("obai", "student", 15, "nein"); // True ist - assertTrue(benutzer instanceof Studenten); + assertTrue(benutzer instanceof Student); String bibKartenNummer = "K1000"; assertTrue(benutzer.getBibAusweis().getKartenNummer().equalsIgnoreCase(bibKartenNummer)); diff --git a/Bibliotheksverwaltungssystem/src/domain/fassade/UserAnmeldenTest.java b/Bibliotheksverwaltungssystem/src/domain/fassade/UserAnmeldenTest.java index 13039cb..fd53b6e 100644 --- a/Bibliotheksverwaltungssystem/src/domain/fassade/UserAnmeldenTest.java +++ b/Bibliotheksverwaltungssystem/src/domain/fassade/UserAnmeldenTest.java @@ -6,8 +6,8 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import domain.ExceptionsKlassen.BenutzerNichtGefundenException; -import domain.ExceptionsKlassen.FalscheEingabeException; +import domain.exceptionsKlassen.BenutzerNichtGefundenException; +import domain.exceptionsKlassen.FalscheEingabeException; class UserAnmeldenTest { diff --git a/Bibliotheksverwaltungssystem/src/domain/Medium/Brettspiel.java b/Bibliotheksverwaltungssystem/src/domain/medium/Brettspiel.java similarity index 95% rename from Bibliotheksverwaltungssystem/src/domain/Medium/Brettspiel.java rename to Bibliotheksverwaltungssystem/src/domain/medium/Brettspiel.java index b44bfd9..050961b 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Medium/Brettspiel.java +++ b/Bibliotheksverwaltungssystem/src/domain/medium/Brettspiel.java @@ -1,4 +1,4 @@ -package domain.Medium; +package domain.medium; public class Brettspiel extends Medium { diff --git a/Bibliotheksverwaltungssystem/src/domain/Medium/Buch.java b/Bibliotheksverwaltungssystem/src/domain/medium/Buch.java similarity index 95% rename from Bibliotheksverwaltungssystem/src/domain/Medium/Buch.java rename to Bibliotheksverwaltungssystem/src/domain/medium/Buch.java index bbb4d7e..45af7ca 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Medium/Buch.java +++ b/Bibliotheksverwaltungssystem/src/domain/medium/Buch.java @@ -1,4 +1,4 @@ -package domain.Medium; +package domain.medium; public class Buch extends Medium { diff --git a/Bibliotheksverwaltungssystem/src/domain/Medium/Cd.java b/Bibliotheksverwaltungssystem/src/domain/medium/Cd.java similarity index 95% rename from Bibliotheksverwaltungssystem/src/domain/Medium/Cd.java rename to Bibliotheksverwaltungssystem/src/domain/medium/Cd.java index cccf71b..c893357 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Medium/Cd.java +++ b/Bibliotheksverwaltungssystem/src/domain/medium/Cd.java @@ -1,4 +1,4 @@ -package domain.Medium; +package domain.medium; import java.util.Date; diff --git a/Bibliotheksverwaltungssystem/src/domain/Medium/Dvd.java b/Bibliotheksverwaltungssystem/src/domain/medium/Dvd.java similarity index 95% rename from Bibliotheksverwaltungssystem/src/domain/Medium/Dvd.java rename to Bibliotheksverwaltungssystem/src/domain/medium/Dvd.java index 46da76f..83fdbd6 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Medium/Dvd.java +++ b/Bibliotheksverwaltungssystem/src/domain/medium/Dvd.java @@ -1,4 +1,4 @@ -package domain.Medium; +package domain.medium; public class Dvd extends Medium { diff --git a/Bibliotheksverwaltungssystem/src/domain/Medium/Medium.java b/Bibliotheksverwaltungssystem/src/domain/medium/Medium.java similarity index 96% rename from Bibliotheksverwaltungssystem/src/domain/Medium/Medium.java rename to Bibliotheksverwaltungssystem/src/domain/medium/Medium.java index 8a2f063..21d8f2d 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Medium/Medium.java +++ b/Bibliotheksverwaltungssystem/src/domain/medium/Medium.java @@ -1,4 +1,4 @@ -package domain.Medium; +package domain.medium; public abstract class Medium { diff --git a/Bibliotheksverwaltungssystem/src/domain/Medium/Mediumverwalter.java b/Bibliotheksverwaltungssystem/src/domain/medium/Mediumverwalter.java similarity index 97% rename from Bibliotheksverwaltungssystem/src/domain/Medium/Mediumverwalter.java rename to Bibliotheksverwaltungssystem/src/domain/medium/Mediumverwalter.java index 9793c5c..108f394 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Medium/Mediumverwalter.java +++ b/Bibliotheksverwaltungssystem/src/domain/medium/Mediumverwalter.java @@ -1,4 +1,4 @@ -package domain.Medium; +package domain.medium; public class Mediumverwalter { diff --git a/Bibliotheksverwaltungssystem/src/domain/Medium/Videospiel.java b/Bibliotheksverwaltungssystem/src/domain/medium/Videospiel.java similarity index 96% rename from Bibliotheksverwaltungssystem/src/domain/Medium/Videospiel.java rename to Bibliotheksverwaltungssystem/src/domain/medium/Videospiel.java index ceeae36..938317b 100644 --- a/Bibliotheksverwaltungssystem/src/domain/Medium/Videospiel.java +++ b/Bibliotheksverwaltungssystem/src/domain/medium/Videospiel.java @@ -1,4 +1,4 @@ -package domain.Medium; +package domain.medium; import java.util.Date; diff --git a/Bibliotheksverwaltungssystem/src/main/Main.java b/Bibliotheksverwaltungssystem/src/main/Main.java index 1510bc0..a2fe95b 100644 --- a/Bibliotheksverwaltungssystem/src/main/Main.java +++ b/Bibliotheksverwaltungssystem/src/main/Main.java @@ -1,6 +1,6 @@ package main; -import domain.ExceptionsKlassen.*; +import domain.exceptionsKlassen.*; import tui.Tui; public class Main { diff --git a/Bibliotheksverwaltungssystem/src/MedienHinzüfugen/MedienHinzufügen.java b/Bibliotheksverwaltungssystem/src/medienHinzüfugen/MedienHinzufügen.java similarity index 96% rename from Bibliotheksverwaltungssystem/src/MedienHinzüfugen/MedienHinzufügen.java rename to Bibliotheksverwaltungssystem/src/medienHinzüfugen/MedienHinzufügen.java index a648fd3..485ddc1 100644 --- a/Bibliotheksverwaltungssystem/src/MedienHinzüfugen/MedienHinzufügen.java +++ b/Bibliotheksverwaltungssystem/src/medienHinzüfugen/MedienHinzufügen.java @@ -1,8 +1,8 @@ -package MedienHinzüfugen; +package medienHinzüfugen; import java.util.Scanner; -import domain.ExceptionsKlassen.FalscheEingabeException; +import domain.exceptionsKlassen.FalscheEingabeException; import domain.fassade.BibSystem; public class MedienHinzufügen { diff --git a/Bibliotheksverwaltungssystem/src/tui/Tui.java b/Bibliotheksverwaltungssystem/src/tui/Tui.java index 46009d5..2df3ffe 100644 --- a/Bibliotheksverwaltungssystem/src/tui/Tui.java +++ b/Bibliotheksverwaltungssystem/src/tui/Tui.java @@ -3,9 +3,9 @@ package tui; import java.util.ArrayList; import java.util.Scanner; -import MedienHinzüfugen.MedienHinzufügen; -import domain.ExceptionsKlassen.*; +import domain.exceptionsKlassen.*; import domain.fassade.BibSystem; +import medienHinzüfugen.MedienHinzufügen; public class Tui { private BibSystem fassade;