Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Restaurant c lient application class and service classes Create a NetBeans project named RestaurantClient following the instructions provided in the Starting a NetBeans Project

//

Restaurant c

lient application class and service classes

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

class

es i

n 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

mai

n(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 r

2

and output an appropriate message indicating if the

objects are equal */

// Your code here

/* Using the appropriate mut

ato

r method (set method)

on Restaurant object r

2, 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 ou

tput using the format m

ethod

on the Decimalformat clas

s

.

}

}

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 o

verloaded constructor

* Allows client to set beginning value for name

* This con

stru

ctor 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

return

s

a

string representation of the store

*/

// Your code here

/**

* equals method

* Compares two Store objects for the same field value

s

* accepts store reference as parameter

*

return boolea

n, true if this object

* has the same field value

s 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, m

utator 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 constr

uctor

takes three p

arameters

.

Calls

the overloaded

super

constructor

with the store name and c

alls

appropriate

mutator methods

to update instance variables of

Restaurant class.

*

/

// Your code here

/*

getPeopleServed method

*/

// Your code here

/*

getAveragePrice me

thod

.

Returns

the average price

per meal

people pay at the restaurant

*/

// Your code here

/*

setPeopleServed m

utator method:

Allows client to

set value of people

s

erved

every year

. I

f

number of

people served yearly

is negative, then

number of

people served yearly

i

s not changed

and a message is

output indicating that the number of people served

cannot be less than zero

*/

// Your code here

/*

setAveragePrice m

utator

method:

Allows client to

set value of

the

average

p

rice

. I

f

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 r

eturn a string

representation of the restaurant

including

the

Store

name

the number of people served and the average price

per person

.

*/

// Your code here

/* e

quals method

c

ompares two

Restaurant

objects for

the same field values

. You will need to compare the

superclass Store name as well as th

e 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 objec

t 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

}

When your application has been successfully compiled and executed, Zip the

RestaurantClient

project

folder. After the

RestaurantClient

project folder has been successfully compressed, upload the zipp

ed

folder to your Blackboard account for Programming Exercise 4.

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

Logic In Databases International Workshop Lid 96 San Miniato Italy July 1 2 1996 Proceedings Lncs 1154

Authors: Dino Pedreschi ,Carlo Zaniolo

1st Edition

3540618147, 978-3540618140

More Books

Students also viewed these Databases questions

Question

Describe the new structures for the HRM function. page 676

Answered: 1 week ago