Answered step by step
Verified Expert Solution
Link Copied!

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 Customer(String name, String phone){
super();
this.name = name;
this.phone = phone;
}
public Customer(String 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 setPhone(String phone){
this.phone = phone;
}
public int getSeat(){
return seat;
}
public void setSeat(int seat){
this.seat = seat;
}
public boolean isHighchair(){
return highchair;
}
public void setHighchair(boolean 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 one-dimensional Customer array stores the current customer information (use the basic array instead of ArrayList)//referred as currList
Number of customers in currList--initial to 0
A one-dimensional Customer array used as waitlist stored customer who would like to wait (use the basic array instead of ArrayList)//referred as waitLine
Number of customers in waitList--initial to 0*/
//1. 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 10-- new to get memory allocation*/
//2. 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*/
//3. 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*/
//4. Search
/* A search method accepts a customer as parameter and return an int
o Return 0 if the customer is found in currList
o Return 1 is the customer is found in waitList
o Return -1 otherwise.*/
//5. 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 10 customers, add this new customer into the waitList. Print message to show the result*/
//6.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 main(String[] args){
// TODO Auto-generated method stub
Customer c1=new Customer("Jacob","1111",3,false);
Customer c2=new Customer("Mike","2222",2,false);
Customer c3=new Customer("Anna","3333",5,true);
Customer c4=new Customer("Emily","4444",4,false);
Customer c5=new Customer("Owen","5555",2,false);
Customer c6=new Customer("Sara","6666",3,false);
Customer c7=new Customer("Chris","7777",4,true);
Customer c8=new Customer("Romana","8888",2,false);
Restaurant r= new Restaurant(15);
//add by calling r.youraddmethod()--add multiple customer to test when the currList is full, go to the waitList
//remove by calling r.removemethod()
//search by calling r.search()
//check by using the print or display method
}
}
image text in transcribed

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

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

He is a man who you cannot but respect.

Answered: 1 week ago

Question

1. What is the origin of the communication discipline?

Answered: 1 week ago

Question

2. What methods do communication scholars use to conduct research?

Answered: 1 week ago