summaryrefslogtreecommitdiffstats
path: root/sandbox/dougsleite/travelagency/src/main/java/hotel/HotelRoom.java
blob: 124d8a3b576d0211bc7d5b7cc278b91a2fc553b8 (plain)
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
/*
 * 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;
    }
}