public void koop(Goed g) throws KoopException { /* We can't buy when our budget doesn't allow for it */ if (this.budget < g.getWaarde()) { throw new KoopException("budget van " + this.naam + " niet toereikend"); } this.budget -= g.getWaarde(); this.goederen.add(g); }
public void verkoop(Goed g, Eigenaar koper) throws KoopException { /* We can't sale if we dont own it */ if (!this.goederen.contains(g)) { throw new KoopException(this.naam + " heeft het goed niet in zijn bezit"); } /* Throws KoopException when buyer doesn't have sufficient budget. */ koper.koop(g); this.budget += g.getWaarde(); this.goederen.remove(g); }