|
12345678910111213141516171819202122232425262728 |
- class Isbod {
- private String[] ansatte;
- private int antallAnsatte;
-
- public void ansett(String navn) throws Exception {
- if (antallAnsatte + 1 > ansatte.length)
- throw new Exception("Du kan ikke ansette saa mange folk.");
- else
- ansatte[antallAnsatte++] = navn;
- }
-
- public void giSistemannSparken() throws Exception {
- if (antallAnsatte - 1 <= 0)
- throw new Exception("Det er ikke flere ansatte igjen.");
- else
- ansatte[--antallAnsatte] = null;
- }
-
- public void printAlleAnsatte() {
- for (int i = 0; i < antallAnsatte; ++i) {
- System.out.println(ansatte[i]);
- }
- }
-
- Isbod() {
- ansatte = new String[10];
- }
- }
|