Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Based on the class BCity in the last question, write a new Java class named BSFCity for modeling Better Smoke-Free Cities with the following requirements.

image text in transcribed

image text in transcribed

Based on the class BCity in the last question, write a new Java class named BSFCity for modeling Better Smoke-Free Cities with the following requirements. a) This BSFCity class is a public subclass of the given class BCity. o This class has a specific instance field of string type, named sFreeRule, representing a specific Smoke-Free rule governing the Better Smoke-Free city. o It has one constructor with the same set of parameters as its direct superclass. The constructor body simply calls the corresponding constructor of its superclass properly. [4 marks] e o GH O b) It has 2 public methods: The first method setsFreeRule () is for setting the specific field, the "Smoke-Free rule. The method accepts one input argument rule of string type and has no return. This method body only sets the specific field with the input parameter value. The second method overrides the method of its direct superclass for displaying information. The method body first calls the overridden method of the superclass. o The method finally displays an extra line to show the specific Smoke-Free rule, as sample program output below. O van Old Statele Sample (Suppose the specific Smoke-Free rule string is: "LAW of SMOKE-FREE") OF City: BSF City, Pop: 8 Rule 21 Rule 22 Smoke-Free Rule: LAW of SMOKE-FREE Son Colmar 0 c) This class includes the main method, the entry point for starting the program. This main method body first creates an array of City which contains 2 related city objects representing the given two cities listed in the table below. This main method then calls the related method to set the smoke-free city object in the array a specific Smoke-Free rule string with format: "LAW of " E.g. "LAW of CHAN Tai Man" if your full name is CHAN Tai Man. This main method finally calls the related method to display the smoke-free city object in the array, as sample program output below. * NO more than 9 statement lines are allowed in the main () method body. O AKU Index 0 List of Rules Name "A City" "BSF City" Given Two Cities Population Type 2 City 8 BSFCity 1 "Rule 21", "Rule 22" Sample Program Output (Suppose student's full name is CHAN Tai Man) City: BSF City, Pop: 8 Rule 21 Rule 22 Smoke-Free Rule: LAW of CHAN Tai Man

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

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

3. Identify challenges to good listening and their remedies

Answered: 1 week ago

Question

4. Identify ethical factors in the listening process

Answered: 1 week ago