University stuff.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627
  1. class Bol<T> {
  2. private T dyr;
  3. Bol() {
  4. this.dyr = null;
  5. }
  6. Bol(T dyr) {
  7. this.dyr = dyr;
  8. }
  9. public boolean erTomt() {
  10. return dyr == null;
  11. }
  12. public void settInn(T dyr) throws Exception {
  13. if (!erTomt()) {
  14. throw new Exception("Bolet er ikke tomt!");
  15. }
  16. this.dyr = dyr;
  17. }
  18. public T hent() throws Exception {
  19. return dyr;
  20. }
  21. }