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.

Isbod.java 629B

12345678910111213141516171819202122232425262728
  1. class Isbod {
  2. private String[] ansatte;
  3. private int antallAnsatte;
  4. public void ansett(String navn) throws Exception {
  5. if (antallAnsatte + 1 > ansatte.length)
  6. throw new Exception("Du kan ikke ansette saa mange folk.");
  7. else
  8. ansatte[antallAnsatte++] = navn;
  9. }
  10. public void giSistemannSparken() throws Exception {
  11. if (antallAnsatte - 1 <= 0)
  12. throw new Exception("Det er ikke flere ansatte igjen.");
  13. else
  14. ansatte[--antallAnsatte] = null;
  15. }
  16. public void printAlleAnsatte() {
  17. for (int i = 0; i < antallAnsatte; ++i) {
  18. System.out.println(ansatte[i]);
  19. }
  20. }
  21. Isbod() {
  22. ansatte = new String[10];
  23. }
  24. }