Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Attatched the question below these are each of the classes Customer.java public class Customer { public String name; private String phone; private int seat; private
Attatched the question below these are each of the classes Customer.java public class Customer
public String name;
private String phone;
private int seat;
private boolean highchair;
public CustomerString name, String phone
super;
this.name name;
this.phone phone;
public CustomerString name, String phone, int seat, boolean highchair
super;
this.name name;
this.phone phone;
this.seat seat;
this.highchair highchair;
public String getPhone
return phone;
public void setPhoneString phone
this.phone phone;
public int getSeat
return seat;
public void setSeatint seat
this.seat seat;
public boolean isHighchair
return highchair;
public void setHighchairboolean highchair
this.highchair highchair;
override the toString method here to print the customer information in the way you want
override the equals method inherited from Object class
Return true if two customers name and phone number are the same. False otherwise.
add Comparable interface and then implement compareTo method
the comparison is based on seat.
If a customer has a larger seat than another customer, it will be considered as a larger customer.
restaurant.java public class Restaurant
maximum seat
A onedimensional Customer array stores the current customer information use the basic array instead of ArrayListreferred as currList
Number of customers in currListinitial to
A onedimensional Customer array used as waitlist stored customer who would like to wait use the basic array instead of ArrayListreferred as waitLine
Number of customers in waitListinitial to
Constructor
A constructor that initializes all data fields.
o Initialize maximum seat with a passed parameter
o Initialize currList with maximum seat new to get memory allocation
o Initialize waitList with size new to get memory allocation
display or print
A Method displays the first n elements either on the currList or waitList
o This method accepts two parameters, one is a customer array, and the other is an int value
o If the number of elements in the passed list is less than n stop when all elements are printed
checkSeat, a help method can be used in other method if there is a need
A method to check how many seats is already taken
o This method will return the number of seats used by customer.
This information can be obtained by sum seat information of all customers in the currList
Search
A search method accepts a customer as parameter and return an int
o Return if the customer is found in currList
o Return is the customer is found in waitList
o Return otherwise.
add
An add method accept a customer as parameter
o If the remaining seat is more than what the customer requires and the new customer is not in the currList or waitList, add this customer to the end of currList. Print message to show the result
o Else if the waitList contains less than customers, add this new customer into the waitList. Print message to show the result
remove
A remove method accepts a customer as parameter
o If the customer is found in the waitList, remove this customer from waitList
o If the customer is found in the currList, remove this customer from the currList. After that, If the waitList is not empty, move the first element in waitList whose seat is less or equal to the customers seat to currList to fill the spot.
testdriver.java public class testDriver
public static void mainString args
TODO Autogenerated method stub
Customer cnew CustomerJacobfalse;
Customer cnew CustomerMikefalse;
Customer cnew CustomerAnnatrue;
Customer cnew CustomerEmilyfalse;
Customer cnew CustomerOwenfalse;
Customer cnew CustomerSarafalse;
Customer cnew CustomerChristrue;
Customer cnew CustomerRomanafalse;
Restaurant r new Restaurant;
add by calling ryouraddmethodadd multiple customer to test when the currList is full, go to the waitList
remove by calling rremovemethod
search by calling rsearch
check by using the print or display method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started