University stuff.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. class Oblig2 {
  2. public static void main(String[] args) throws Exception {
  3. test();
  4. Hylle<Bok> bokhylle = new Hylle<>(100);
  5. Bok bok1 = new Bok("foo", "bar");
  6. Bok bok2 = new Bok("foo2", "bar2");
  7. Bok bok3 = new Bok("foo3", "bar3");
  8. bokhylle.settInn(0, bok1);
  9. bokhylle.settInn(1, bok2);
  10. bokhylle.settInn(2, bok3);
  11. }
  12. public static void test() throws Exception {
  13. Tester t = new Tester();
  14. String desc;
  15. Bok b = new Bok("foo", "bar");
  16. Hylle<Bok> h;
  17. { desc = "En plass paa hyllen blir ledig etter aa ha hentet innholdet";
  18. h = new Hylle<>(1);
  19. h.settInn(0, b);
  20. h.hent(0);
  21. if (h.hent(0) == null)
  22. t.pass(desc);
  23. else
  24. t.fail(desc);
  25. }
  26. { desc = "En hylle godkjenner ikke at en plasserer noe i en plass som ikke eksisterer";
  27. h = new Hylle<>(1);
  28. try {
  29. h.settInn(1, b);
  30. t.fail(desc);
  31. } catch (Exception ex) {
  32. t.pass(desc);
  33. }
  34. }
  35. { desc = "En faar det samme objektet tilbake etter aa ha satt det inn i hyllen";
  36. h = new Hylle<>(1);
  37. h.settInn(0, b);
  38. if (h.hent(0) == b)
  39. t.pass(desc);
  40. else
  41. t.fail(desc);
  42. }
  43. { desc = "En kan ikke plassere noe i en plass som allerede er full";
  44. h = new Hylle<>(1);
  45. Bok b2 = new Bok("foo2", "bar2");
  46. h.settInn(0, b);
  47. try {
  48. h.settInn(0, b2);
  49. t.fail(desc);
  50. } catch (Exception ex) {
  51. t.pass(desc);
  52. }
  53. }
  54. t.printResult();
  55. }
  56. }