class Oblig2 { public static void main(String[] args) throws Exception { test(); Hylle bokhylle = new Hylle<>(100); Bok bok1 = new Bok("foo", "bar"); Bok bok2 = new Bok("foo2", "bar2"); Bok bok3 = new Bok("foo3", "bar3"); bokhylle.settInn(0, bok1); bokhylle.settInn(1, bok2); bokhylle.settInn(2, bok3); } public static void test() throws Exception { Tester t = new Tester(); String desc; Bok b = new Bok("foo", "bar"); Hylle h; { desc = "En plass paa hyllen blir ledig etter aa ha hentet innholdet"; h = new Hylle<>(1); h.settInn(0, b); h.hent(0); if (h.hent(0) == null) t.pass(desc); else t.fail(desc); } { desc = "En hylle godkjenner ikke at en plasserer noe i en plass som ikke eksisterer"; h = new Hylle<>(1); try { h.settInn(1, b); t.fail(desc); } catch (Exception ex) { t.pass(desc); } } { desc = "En faar det samme objektet tilbake etter aa ha satt det inn i hyllen"; h = new Hylle<>(1); h.settInn(0, b); if (h.hent(0) == b) t.pass(desc); else t.fail(desc); } { desc = "En kan ikke plassere noe i en plass som allerede er full"; h = new Hylle<>(1); Bok b2 = new Bok("foo2", "bar2"); h.settInn(0, b); try { h.settInn(0, b2); t.fail(desc); } catch (Exception ex) { t.pass(desc); } } t.printResult(); } }