SHOW:
|
|
- or go back to the newest paste.
| 1 | public class Hotel {
| |
| 2 | ||
| 3 | //Class constants and variables | |
| 4 | private static final double ROOM_RATE = 79.95, | |
| 5 | TAX_RATE = 6.5, | |
| 6 | TELEPHONE = 5.75, | |
| 7 | MEAL_RATE = 12.95, | |
| 8 | TIP_RATE = 0.075; | |
| 9 | private static double totalRoom, | |
| 10 | totalTel, | |
| 11 | totalMeal, | |
| 12 | totalTax, | |
| 13 | totalTip, | |
| 14 | totalAmount; | |
| 15 | //Instance variables | |
| 16 | private int noOfNights, noOfGuests; | |
| 17 | private double amountDue, meal, tax, subTotal, total, tip; | |
| 18 | private String roomNumber; | |
| 19 | ||
| 20 | public Hotel(String room) {
| |
| 21 | roomNumber = room; | |
| 22 | noOfGuests = 1; | |
| 23 | noOfNights = 1; | |
| 24 | - | totalRoom = totalRoom + (ROOM_RATE * noOfGuests * noOfNights); |
| 24 | + | totalRoom = totalRoom + (ROOM_RATE * noOfNights * noOfGuests); |
| 25 | totalTel = totalTel + TELEPHONE; | |
| 26 | totalMeal = totalMeal + (MEAL_RATE * noOfNights * noOfGuests); | |
| 27 | totalTip = TIP_RATE * (subTotal + meal + TELEPHONE); | |
| 28 | } | |
| 29 | - | this.noOfGuests = 1; |
| 29 | + | |
| 30 | - | this.noOfNights = nights; |
| 30 | + | |
| 31 | roomNumber = room; | |
| 32 | noOfGuests = 1; | |
| 33 | noOfNights = nights; | |
| 34 | totalRoom = totalRoom + (ROOM_RATE * nights * noOfGuests); | |
| 35 | - | this(room); |
| 35 | + | totalTel = totalTel + TELEPHONE; |
| 36 | - | this.noOfNights = nights; |
| 36 | + | totalMeal = totalMeal + (MEAL_RATE * nights * noOfGuests); |
| 37 | - | this.noOfGuests = guests; |
| 37 | + | totalTip = TIP_RATE * (subTotal + meal + TELEPHONE); |
| 38 | } | |
| 39 | ||
| 40 | public Hotel(String room, int nights, int guests) {
| |
| 41 | roomNumber = room; | |
| 42 | noOfNights = nights; | |
| 43 | noOfGuests = guests; | |
| 44 | totalRoom = totalRoom + (ROOM_RATE * nights * guests); | |
| 45 | totalTel = totalTel + TELEPHONE; | |
| 46 | totalMeal = totalMeal + (MEAL_RATE * nights * guests); | |
| 47 | totalTip = TIP_RATE * (subTotal + meal + TELEPHONE); | |
| 48 | } | |
| 49 | ||
| 50 | //mutator for individual summaries | |
| 51 | - | |
| 51 | + | |
| 52 | - | //mutator for addition of more nights |
| 52 | + | |
| 53 | - | public void addNights(int nights) {
|
| 53 | + | |
| 54 | - | noOfNights = noOfNights + nights; |
| 54 | + | |
| 55 | - | totalRoom = totalRoom + (ROOM_RATE * nights * noOfGuests); |
| 55 | + | |
| 56 | tip = TIP_RATE * (subTotal + meal + TELEPHONE); | |
| 57 | - | //mutator for addition of more guests |
| 57 | + | |
| 58 | - | public void addGuest(int guests) {
|
| 58 | + | |
| 59 | - | noOfGuests = noOfGuests + guests; |
| 59 | + |