123456789101112131415161718192021222324252627 |
- class Bol<T> {
- private T dyr;
-
- Bol() {
- this.dyr = null;
- }
-
- Bol(T dyr) {
- this.dyr = dyr;
- }
-
- public boolean erTomt() {
- return dyr == null;
- }
-
- public void settInn(T dyr) throws Exception {
- if (!erTomt()) {
- throw new Exception("Bolet er ikke tomt!");
- }
-
- this.dyr = dyr;
- }
-
- public T hent() throws Exception {
- return dyr;
- }
- }
|