Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a NetBeans project named RestaurantClient following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. Add

Create a NetBeans project named RestaurantClient following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. Add two service classes to the project. A class named Store which will be a direct superclass of a class named Restaurant. Class Restaurant will be a subclass of Store.

After you have created your NetBeans Project your application and service classes in your RestaurantClient project should contain the following executable code for the RestaurantClient, Store and Restaurant classes: RestaurantClient application class:

package restaurantclient;

public class RestaurantClient {

public static void main(String[] args) { } }

Store service class:

package restaurantclient;

public class Store {

}

Restaurant service class:

package restaurantclient;

public class Restaurant extends Store{

}

In the RestaurantClient application class main method code the instructions to perform the tasks indicated in the remarks :

package restaurantclient;

public class RestaurantClient{

public static void main( String [] args ){

/* Declare two object references of type Restaurant r1 and r2 and instantiate two Restaurant objects passing three arguments to the constructor for the class. Use different values for each class object. */

// Your code here

/* Output the restaurant name, number of people served and average price per person from both object references r1 and r2 by implicitly calling the toString method to return the data */

// Your code here

/* Using the appropriate mutator methods on Restaurant object reference r2, change the value of the number of people served and the average price per person to the same values in Restaurant object reference r1. Do not change the restaurant name. Use the appropriate set methods.*/

// Your code here

/* Using the equals method and a selection control structure (if statement), compare objects r1 and r2 and output an appropriate message indicating if the objects are equal */

// Your code here

/* Using the appropriate mutator method (set method) on Restaurant object r2, change the name of the restaurant to the same name in Restaurant object reference r1. */

// Your code here

/* Again, using the equals method and a selection control structure (if statement), compare objects s1 and s2 and output an appropriate message indicating if the objects are equal */

// Your code here

/* Output the average annual taxes for Restaurant object r1. Format the output using the format method on the Decimalformat class. }

}

In the Store service class code the instructions to define your Store service class structure with the appropriate constructors, mutator methods, accessor methods as well as a toString and an equals method :

package restaurantclient;

public class Store {

/* Declare two instance variables to represent the store name and tax rate. Tax rate identifier will be assigned a constant value. */

// Your code here

/** * Code an overloaded constructor

* Allows client to set beginning value for name

* This constructor takes one parameter

* Calls mutator (setName) method */

// Your code here

/** getName method

* @return a String, the name of the store */

// Your code here

/**

*setName mutator method:

* Allows client to set value of name */

// Your code here

/**

* toString method accepts no parameters returns a string representation of the store */

// Your code here

/**

* equals method

* Compares two Store objects for the same field values

* accepts store reference as parameter

* return boolean, true if this object

* has the same field values as the parameter reference object */

// Your code here }

In the Restaurant service class code the instructions to define your Restaurant service class structure with the appropriate constructors, mutator methods, accessor methods as well as a toString and an equals method. Class Restaurant extends class Store:

package restaurantclient;

public class Restaurant extends Store {

/* Declare two instance variables to represent the the number of people served yearly and the average price per meal */

// Your code here /

*Overloaded constructor: Allows client to set beginning value for peopleServed, averagePrice and set the store name in the super class. This constructor takes three parameters. Calls the overloaded super constructor with the store name and calls appropriate mutator methods to update instance variables of Restaurant class. */

// Your code here

/* getPeopleServed method */

// Your code here

/* getAveragePrice method. Returns the average price per meal people pay at the restaurant */

// Your code here

/* setPeopleServed mutator method: Allows client to set value of people served every year. If number of people served yearly is negative, then number of people served yearly is not changed and a message is output indicating that the number of people served cannot be less than zero */

// Your code here

/* setAveragePrice mutator method: Allows client to set value of the average price. If the new value of average price per meal is negative, then the average price per meal is not changed and a message is output indicating that the average price per meal cannot be less than zero */

// Your code here

/* toString method will return a string representation of the restaurant including the Store name the number of people served and the average price per person. */

// Your code here

/* equals method compares two Restaurant objects for the same field values. You will need to compare the superclass Store name as well as the number of people served and the average price per person in the Restaurant class to determine equality. You can use super.getName() to return the superclass Store name for comparison or code the super.equals(Object o) method passing your restaurant object reference as an argument to the superclass equals method to compare the name. Returns a Boolean. */

// Your code here

/* averageTaxes method. Computes the average annual taxes paid by the restaurant. Returns a double. Computes the average annual taxes paid by the restaurant */

// Your code here

}

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

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago