Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

B5. * Students should finish reading the whole question first, before answering. Based on the class BCity in the last question, write a new Java

image text in transcribed

B5. * Students should finish reading the whole question first, before answering. 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. This class has a specific instance field of string type, named sFreeRule, representing a specific Smoke-Free rule governing the Better Smoke-Free city. 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. O o O 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. The method finally displays an extra line to show the specific Smoke-Free rule, sample program output below. o o O Sample Program Output (Suppose the specific "Smoke-Free rule string is: "LAW of SMOKE-FREE") City: BSF City, Pop: 8 Rule 21 Rule 22 Smoke-Free Rule: LAW of SMOKE-FREE 6/7 " 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 Given Two Cities Index Name Population List of Rules 0 2 "A City" "BSF City" Type City BSFCity 1 8 "Rule 21", "Rule 22" co 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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions