Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java code for the Class Main, based on the classes below, import java.util.ArrayList; public class Customer { private int nationalID; private int firstName;

Write a Java code for the Class Main, based on the classes below, import java.util.ArrayList;

public class Customer { private int nationalID; private int firstName; private int lastName; private String email; private int phoneNumber; private String address; private ArrayList reservations;

public Customer(int nationalID, int firstName, int lastName, String email, int phoneNumber, String address, ArrayList reservations) { this.nationalID = nationalID; this.firstName = firstName; this.lastName = lastName; this.email = email; this.phoneNumber = phoneNumber; this.address = address; this.reservations = reservations; }

public int getNationalID() { return nationalID; }

public void setNationalID(int nationalID) { this.nationalID = nationalID; }

public int getFirstName() { return firstName; }

public void setFirstName(int firstName) { this.firstName = firstName; }

public int getLastName() { return lastName; }

public void setLastName(int lastName) { this.lastName = lastName; }

public String getEmail() { return email; }

public void setEmail(String email) { this.email = email; }

public int getPhoneNumber() { return phoneNumber; }

public void setPhoneNumber(int phoneNumber) { this.phoneNumber = phoneNumber; }

public String getAddress() { return address; }

public void setAddress(String address) { this.address = address; }

public ArrayList getReservations() { return reservations; }

public void setReservations(ArrayList reservations) { this.reservations = reservations; }

public void addCustomer(Customer customer) { this.nationalID = customer.nationalID; this.firstName = customer.firstName; this.lastName = customer.lastName; this.email = customer.email; this.phoneNumber = customer.phoneNumber; this.address = customer.address; }

public void removeCustomer(Customer customer) { this.nationalID = customer.nationalID; this.firstName = customer.firstName; this.lastName = customer.lastName; this.email = customer.email; this.phoneNumber = customer.phoneNumber; this.address = customer.address; }

public void printAll(ArrayList reservations) { for (Reservation x : reservations) { System.out.println(x); } }

@Override public String toString() { return "Customer{" + "nationalID=" + nationalID + ", firstName=" + firstName + ", lastName=" + lastName + ", email='" + email + '\'' + ", phoneNumber=" + phoneNumber + ", address='" + address + '\'' + ", reservations=" + reservations + '}'; } }

_________________

public class Reservation { private int NumOfGuests; private int NumOfNights; private Room room; private Date CheckInDate;

public Reservation(int numOfGuests, int numOfNights, Room room, Date checkInDate) { NumOfGuests = numOfGuests; NumOfNights = numOfNights; this.room = room; CheckInDate = checkInDate; }

public int getNumOfGuests() { return NumOfGuests; }

public void setNumOfGuests(int numOfGuests) { NumOfGuests = numOfGuests; }

public int getNumOfNights() { return NumOfNights; }

public void setNumOfNights(int numOfNights) { NumOfNights = numOfNights; }

public Room getRoom() { return room; }

public void setRoom(Room room) { this.room = room; }

public Date getCheckInDate() { return CheckInDate; }

public void setCheckInDate(Date checkInDate) { CheckInDate = checkInDate; }

@Override public String toString() { return "Reservation{" + "NumOfGuests=" + NumOfGuests + ", NumOfNights=" + NumOfNights + ", room=" + room + ", CheckInDate=" + CheckInDate + '}'; } }

__________________

package com.company;

public class Room { private int BuildingNumber; private int FloorNumber; private int RoomNumber;

public Room(int buildingNumber, int floorNumber, int roomNumber) { BuildingNumber = buildingNumber; FloorNumber = floorNumber; RoomNumber = roomNumber; }

public int getBuildingNumber() { return BuildingNumber; }

public void setBuildingNumber(int buildingNumber) { BuildingNumber = buildingNumber; }

public int getFloorNumber() { return FloorNumber; }

public void setFloorNumber(int floorNumber) { FloorNumber = floorNumber; }

public int getRoomNumber() { return RoomNumber; }

public void setRoomNumber(int roomNumber) { RoomNumber = roomNumber; }

@Override public String toString() { return "Room{" + "BuildingNumber=" + BuildingNumber + ", FloorNumber=" + FloorNumber + ", RoomNumber=" + RoomNumber + '}'; } }

_________________

public class EconomyRoom extends Room { private double CostPerNight; private int NumOfGuests; private int NumOfNights;

public EconomyRoom(int buildingNumber, int floorNumber, int roomNumber, double CostPerNight, int NumOfGuests, int NumOfNights) { super(buildingNumber, floorNumber, roomNumber); this.CostPerNight = CostPerNight; this.NumOfGuests = NumOfGuests; this.NumOfNights = NumOfNights; }

public double getCostPerNight() { return CostPerNight; }

public void setCostPerNight(double costPerNight) { CostPerNight = costPerNight; }

public int getNumOfGuests() { return NumOfGuests; }

public void setNumOfGuests(int numOfGuests) { NumOfGuests = numOfGuests; }

public int getNumOfNights() { return NumOfNights; }

public void setNumOfNights(int numOfNights) { NumOfNights = numOfNights; }

public double getTotal() {return CostPerNight * NumOfNights * NumOfGuests;}

@Override public String toString() { return "EconomyRoom{" + "CostPerNight=" + CostPerNight + ", NumOfGuests=" + NumOfGuests + ", NumOfNights=" + NumOfNights + '}'; } }

________________

public class Date { private int Day; private int Month; private int Year;

public Date(int day, int month, int year) { Day = day; Month = month; Year = year; }

public int getDay() { return Day; }

public void setDay(int day) { Day = day; }

public int getMonth() { return Month; }

public void setMonth(int month) { Month = month; }

public int getYeat() { return Year; }

public void setYear(int year) { Year = year; }

@Override public String toString() { return "Date{" + "Day=" + Day + ", Month=" + Month + ", Year=" + Year+ '}'; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions