Question: Please use Java as coding tool Part A 11 points Restaurant Class 1- (0.75 point) Create a Restaurant class that includes the attributes as summarized
Please use Java as coding tool
Part A 11 points Restaurant Class
1- (0.75 point) Create a Restaurant class that includes the attributes as summarized below:
Restaurant class has the following instance variable:
restaurantName; // restaurant name
restaurantCity; // restaurant city
restaurantType; // type of food served at restaurant.
availableTables; // holding number of available tables.
The class includes a class variables nextReservationNum set to one
2- (1 point) Write a default constructor that sets the instance variables (foodCourt, chicago, fastfood, 10) and another constructor that uses the setters to set the instance variables using parameters.
3- (1.75 point) Create setter and getter for the instance variables and getters for the class variables. Make sure that the number of availableTables is positive.
3-(2.5 point) Create a RestaurantReservations method that allows to use a persons name as a parameter as well as the number of tables and make a reservation for them, if there are enough availableTables, then it reserves the table by reducing the availableTable by the number of table and return the reservation information in the following format: nextReservationNum , persons name, number of tables.
If there isnt enough availableTable for the reservation than it returns no reservation made.
4. (1 point) Create a method releaseTable that takes releaseTables as parameter check if it positive than it increments the availableTables by the releaseTable.
5- (1.25 point) Create a method isNamePalindrome that returns true if the restaurantName is palindrome, a palindrome name is same even when it is read backwords example desserts I stressed
6- (1.75 point) Create a toString method that return the restaurant information in the following format restaurantName (all capital), restaurantCity, restaurantType, availableTables; The restaurantName needs to be capitalized using the String class method also if the restaurant name is too long only display the first 10 letters.
7- (1 point) Create an equal method that compares the Restaurant instance variable to another restaurant instance variables another Restaurant objects instance variables.
Part B (4 points)- Write a client class, RestaurantApp, to test the following of your Restaurant class.
1. (0.5 point) create 2 objects using both constructors; restaurant1 uses the default constructor and restaurant2 uses values of your choice.
2. (1.5point) Use the getter to get each restaurant2 attributes value and set restaurant1 to have the same attributes values.
Use the equal method to check that restaurant1 and restaurant2 are comparable.
3. (0.5 point) Set the class variable nextReservationNum to 10.
4. (0.5 point) Make a reservation under your name for restaurant2 for 2 tables.
5. (1 point) Release the tables reservation of part B-4 and use the toString method to print the restaurant2 information before and after the release.
Using System.out
| void print(anyDataType argument) | prints argument to the standard output device (by default, the Java console) |
| void println(anyDataType argument) | prints argument to the standard output device (Java console) followed by a newline character |
The String Class
| String( String str ) | allocates a String object with the value of str, which can be String object or a String literal |
| String( ) | allocates an empty String |
| int length( ) | returns the number of characters in the String |
| String toUpperCase( ) | returns a copy of the String will all letters uppercase |
| String toLowerCase( ) | returns a copy of the String will all letters lowercase |
| int indexOf(String searchString) | returns the index of the first character of searchString or -1 if not found |
| int indexOf( char searchChar ) | returns the index of the first character of searchChar or -1 if not found |
| String substring(int startIndex, int endIndex) | returns a substring of the String object beginning at the character at index startIndex and ending at the character at index ( endIndex 1 ). |
The Scanner Class
| Scanner( InputStream source ) | creates a Scanner object for reading from source. If source is System.in, this instantiates a Scanner object for reading from the Java console |
| dataType nextDataType( ) | returns the next token in the input stream as a dataType. dataType can be byte, int, short, long, float, double, or boolean |
| String next( ) | returns the next token in the input stream as a String |
| String nextLine( ) | returns the remainder of the line as a String |
The DecimalFormat Class
| DecimalFormat(String pattern ) | instantiates a DecimalFormat object with the format specified by pattern |
| String format(double number) | returns a formatted String representation of number |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
