a876bcd47acf75562aae9a6c51f89820bcefab63
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / HouseManager.java
1 package businessLogic;
2
3 import java.util.Date;
4 import java.util.Vector;
5
6 import dataAccess.DB4oManager;
7 import domain.Account;
8 import domain.Offer;
9 import domain.Owner;
10 import domain.RuralHouse;
11
12 public class HouseManager implements HouseManagerInterface {
13         DB4oManager dbMngr;
14
15         public HouseManager() {
16                 try {
17                         dbMngr = DB4oManager.getInstance();
18                 } catch (Exception e) {
19                         // TODO Auto-generated catch block
20                         e.printStackTrace();
21                 }
22         }
23
24         @Override
25         public boolean registerNewHouse(int houseNumber, Owner owner, String town,
26                         int nRooms, int nKitchens, int nBaths, int nLivings, int nParkings) {
27                 // TODO Auto-generated method stub
28                 if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
29                         return false;
30                 try {
31                         this.dbMngr.storeRuralHouses(new RuralHouse(houseNumber, owner,
32                                         town, nRooms, nKitchens, nBaths, nLivings, nParkings));
33                 } catch (Exception e) {
34                         // TODO Auto-generated catch block
35                         e.printStackTrace();
36                 }
37                 return true;
38
39         }
40
41         @Override
42         public boolean registerNewHouse(int houseNumber, Owner owner,
43                         String description, String town, int nRooms, int nKitchens,
44                         int nBaths, int nLivings, int nParkings) {
45                 // TODO Auto-generated method stub
46                 if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
47                         return false;
48                 try {
49                         this.dbMngr.storeRuralHouses(new RuralHouse(houseNumber, owner,
50                                         description, town, nRooms, nKitchens, nBaths, nLivings,
51                                         nParkings));
52                 } catch (Exception e) {
53                         // TODO Auto-generated catch block
54                         e.printStackTrace();
55                 }
56                 return true;
57         }
58
59         @Override
60         public void modifyHouse(int houseNumber, Owner owner, String description,
61                         String town, int nRooms, int nKitchens, int nBaths, int nLivings,
62                         int nParkings) {
63                 // TODO Auto-generated method stub
64                 
65         }
66         
67         //Maybe returning the offer is not necessary. Depends on GUI implementation.
68         @Override
69         public Offer setOffers(RuralHouse ruralHouse, Date firstDay, Date lastDay,
70                         float price) {
71                 // TODO Auto-generated method stub
72                 try {
73                         return this.dbMngr.createOffer(ruralHouse, firstDay, lastDay, price);
74                 } catch (Exception e) {
75                         // TODO Auto-generated catch block
76                         e.printStackTrace();
77                 }
78                 return null;
79         }
80
81 }