summaryrefslogtreecommitdiffstats
path: root/sandbox/dougsleite/travelagency/src/main/java/hotel/HotelRoom.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/dougsleite/travelagency/src/main/java/hotel/HotelRoom.java')
-rw-r--r--sandbox/dougsleite/travelagency/src/main/java/hotel/HotelRoom.java131
1 files changed, 131 insertions, 0 deletions
diff --git a/sandbox/dougsleite/travelagency/src/main/java/hotel/HotelRoom.java b/sandbox/dougsleite/travelagency/src/main/java/hotel/HotelRoom.java
new file mode 100644
index 0000000000..124d8a3b57
--- /dev/null
+++ b/sandbox/dougsleite/travelagency/src/main/java/hotel/HotelRoom.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package hotel;
+
+public class HotelRoom {
+
+ public static int FLOOR_MARBLE = 0;
+ public static int FLOOR_CARPET = 1;
+ private int bedroomNumber;
+ private boolean hasBath;
+ private boolean hasAirConditioning;
+ private boolean hasCloset;
+ private int floorType;
+ private int id;
+ private boolean isBooked;
+ private int alredyBookedNumber;
+
+ public HotelRoom(int id, int bedroomNumber, boolean hasBath,
+ boolean hasAirConditioning, boolean hasCloset, int floorType) {
+ this.bedroomNumber = bedroomNumber;
+ this.hasBath = hasBath;
+ this.hasAirConditioning = hasAirConditioning;
+ this.hasCloset = hasCloset;
+ this.floorType = floorType;
+ this.alredyBookedNumber = 0;
+ this.id = id;
+ this.isBooked = false;
+ }
+
+ public int getAlreadyBookedNumber() {
+ return alredyBookedNumber;
+ }
+
+ public int book() {
+ if (isBooked == false) {
+ isBooked = true;
+ return ++alredyBookedNumber;
+ }
+ return -1;
+ }
+
+ public boolean unbook() {
+ if (isBooked == true) {
+ isBooked = false;
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isBooked() {
+ return isBooked;
+ }
+
+ public int getBedroomNumber() {
+ return bedroomNumber;
+ }
+
+ public void setBedroomNumber(int bedroomNumber) {
+ this.bedroomNumber = bedroomNumber;
+ }
+
+ public boolean hasBath() {
+ return this.hasBath;
+ }
+
+ public void setHasBath(boolean hasBath) {
+ this.hasBath = hasBath;
+ }
+
+ public boolean hasAirConditioning() {
+ return this.hasAirConditioning;
+ }
+
+ public void setHasAirConditioning(boolean hasAirConditioning) {
+ this.hasAirConditioning = hasAirConditioning;
+ }
+
+ public boolean hasClose() {
+ return this.hasCloset;
+ }
+
+ public void setHasCloset(boolean hasCloset) {
+ this.hasCloset = hasCloset;
+ }
+
+ public int getFloorType() {
+ return floorType;
+ }
+
+ public void setFloorType(int floorType) {
+ this.floorType = floorType;
+ }
+
+ public int getID() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof HotelRoom &&
+ super.equals(obj) &&
+ this.getID() == ((HotelRoom) obj).getID();
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 37 * hash + this.bedroomNumber;
+ hash = 37 * hash + (this.hasBath ? 1 : 0);
+ hash = 37 * hash + (this.hasAirConditioning ? 1 : 0);
+ hash = 37 * hash + (this.hasCloset ? 1 : 0);
+ hash = 37 * hash + this.floorType;
+ return hash;
+ }
+}