package businessLogic; import java.rmi.RemoteException; import java.util.Vector; import dataAccess.DB4oManager; import domain.Owner; import domain.RuralHouse; public class HouseManager implements HouseManagerInterface { private DB4oManager dbMngr; public HouseManager() { try { dbMngr = DB4oManager.getInstance(); } catch (Exception e) { e.printStackTrace(); } } private boolean suitsRegulations(int nKitchens, int nBaths, int nLivings) { if (nKitchens < 1 || nLivings < 3 || nBaths < 2) return false; else return true; } @Override public boolean registerNewHouse(RuralHouse rh) { boolean stored = false; if (!suitsRegulations(rh.getFeatures().getnKitchens(), rh.getFeatures() .getnBaths(), rh.getFeatures().getnKitchens())) return false; stored = this.dbMngr.storeRuralHouses(rh); return stored; } public void removeHouse(RuralHouse rh, Owner owner) { Vector temp = owner.getRuralHouses(); temp.remove(rh); this.dbMngr.removeHouse(rh, owner); } public Vector getHouses(String name,String town, int nBed, int nKit, int nBath, int nPark, int nLiv) { return this.dbMngr.getRuralHouses(name ,town, nBed, nKit, nBath, nPark, nLiv); } @Override public Vector getAllRuralHouses() throws RemoteException, Exception { return dbMngr.getAllRuralHouses(); } // For future implementation // @Override // public void modifyHouse(int houseName, Owner owner, String description, // String town, int nRooms, int nKitchens, int nBaths, int nLivings, // int nParkings) { // // TODO Auto-generated method stub // // } // Maybe returning the offer is not necessary. Depends on GUI // implementation. }