University stuff.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

123456789101112131415161718192021222324252627282930
  1. class Hylle<T> implements GenHylle<T> {
  2. private int storrelse;
  3. private T[] arr;
  4. Hylle(int storrelse) {
  5. this.storrelse = storrelse;
  6. this.arr = (T[])(new Object[storrelse]);
  7. }
  8. public int hentStorrelse() {
  9. return storrelse;
  10. }
  11. public void settInn(int plass, T ting) throws Exception {
  12. if (arr[plass] == null)
  13. arr[plass] = ting;
  14. else
  15. throw new Exception("Plass "+plass+" er ikke ledig.");
  16. }
  17. public boolean erLedig(int plass) throws Exception {
  18. return arr[plass] == null;
  19. }
  20. public T hent(int plass) {
  21. T ting = arr[plass];
  22. arr[plass] = null;
  23. return ting;
  24. }
  25. }