Probeklausur „Library"

Härter als Zoo. Genau gleiche Pattern, neue Vokabeln.

Domäne
Buch · Regal · Bibliothek
  • Borrower (Interface) – Card getCard()
  • CardString level ("STD","PREMIUM","ALL"), boolean active
  • Professor implements Borrower – Konstruktor nur Name, Card "ALL"+true selbst erzeugt
  • Pupil implements Borrower – Name + Card
  • Shelf (abstract) – analog Room: floor (Etage), maxBooks, books, statisches SHELVES, Comparable
  • RareSection extends Shelf – mit Borrower curator, MAX 10
  • OpenShelf extends Shelf – Eintritt nur bei active Card oder level "ALL"
  • SealedShelf extends Shelf – nie zugänglich
  • Library – Name + Shelves, überladene Konstruktoren, Etagen 1/3/5 = RareSection
  • LibraryMain – main

Aufgabe 1 – Card 2 P

Klasse Card mit String level, boolean active, Konstruktor + zwei Getter.

Aufgabe 2 – Professor 3 P

Professor implements Borrower. Konstruktor nur Name. Card intern erzeugt: new Card("ALL", true).

Aufgabe 3 – Shelf (abstract) 9 P

Wie Room: SHELVES statisch, floor, maxBooks, books, isFree(), enter(Borrower) throws NotAllowedException, compareTo(Shelf).

Aufgabe 4 – RareSection 5 P

MAX 10. Borrower curator. isCuratorPresent() mit null-Check. enter: Wenn curator schon da und neuer Borrower instanceof Professor → Exception. Sonst: wenn instanceof Professor → curator setzen. Schließlich super.enter.

Aufgabe 5 – OpenShelf 4 P

Eintritt nur wenn card.isActive() oder "ALL".equals(card.getLevel()).

Aufgabe 6 – Library 6 P

Überladene Konstruktoren (Library(String)this(name, 6)). Voll-Konstruktor: Etagen 1/3/5 → RareSection, sonst OpenShelf.

Aufgabe 7 – LibraryMain 3 P

main: Library erzeugen, Professor + Pupil erzeugen, for-Each über shelves, enter mit try/catch.