-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHoteManagementSystem.java
More file actions
161 lines (131 loc) · 3.58 KB
/
Copy pathHoteManagementSystem.java
File metadata and controls
161 lines (131 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//base class
//always try to decouple two classes so that updating one class oesnt have other class dpedency like here
//updating location shall be done separately.
//solid principle: Single responsiblity
class Hotel{
String name;
int hotelId;
Location hotelLocation;
List<Room> roomList;
}
class Location{
String country;
String state;
String city;
String street;
String pin;
}
class Room{
String roomNumber;
RoomStyle roomStyle;
RoomStatus roomStatus;
Double bokingPrice;
List<RoomKey> roomKeys;
List<HouseKeepingLog> houseKeepingLogs;
}
public enum RoomStyle{
STANDARD, DELUX, SUITE;
}
public enum RoomStaus{
AVAILABLE, RESERVED, NOT_AVAILABLE, OCCUPIED, SERVICE_IN_PROGRESS,
}
class RoomKey{
String keyId;
String barCode;
Date issuedAt;
Boolean isActive;
Boolean isMaster;
public void assignRoom(Room room); // whenever a key is initialised, it also assigns a particular room to it.
}
class HouseKeepingLog{
String description;
Date startDate;
int duration;
HouseKeeper houseKeeper;
public void addRoom(Room room);
}
//lets go to actors defined in use-case diagram
//out of 5 actors, 4 are of type person and hence will use inheritance for this
abstract class Person{
String name;
Account accountDetails;
String phone;
}
public class Account{
String userName;
String password;
AccontStatus accountStatus;
}
public enum AccontStatus{
ACTIVE, CLOSED, BLOCKED;
}
class houseKeeper extends Person{
public List<Rooms> getRoomServiced(Date date); // in a given date, give al the rooms which is serviced by this houskeeper
}
class Guest extends Person{
Search searchObj;
Booking bookingObj;
public List<Room> getAllBokings();
}
class Receptionist extends Person{
Search searchObj;
Booking bookingObj;
public void checkInGuest(Guest guest, RoomBooking bookingInfo);
public void checkOutGuest(Guest guest, RoomBooking bookingInfo);
}
class Admin extends Person{
public void addRoom(Room roomDetails);
public void deleteRoom(String roomNumber);
public void editRoom(Room roomDetails);
}
class Search{
public List<Room> serachRoom(RoomStyle roomStyle, Date searchDate, int duration);
}
class Booking{
public RoomBooking createBooking(Guest guestInfo);
public RoomBooking cancelBooking(int bookingId);
}
class RoomBooking{
String bookingId;
Date startDate;
int durationInDays;
BookingStatus bookingStatus;
List<Guest> guestList;
List<Room> roomList;
BaseRoomCharge totalRoomCharges;
}
public enum BookingStatus{
}
/*
Decorator pattern to add up new chages on top of base charges
*/
interface BaseRoomCharge{
Double getCost();
}
class RoomCharge implements BaseRoomCharge{
double cost;
double getCost(){
return cost;
}
void setCost(double cost){
this.cost = cost;
}
}
class RoomServiceCharge implements BaseRoomCharge{
double cost;
BaseRoomCharge baseRoomCharge;
Double getCost(){
doubt newCost = baseRoomCharge.getCost() + cost;
baseRoomCharge.setCost(newCost);
return baseRoomCharge.getCost();
}
}
class InRoomPurchaseCharges implements BaseRoomCharge{
double cost;
BaseRoomCharge baseRoomCharge;
Double getCost(){
doubt newCost = baseRoomCharge.getCost() + cost;
baseRoomCharge.setCost(newCost);
return baseRoomCharge.getCost();
}
}