Answered step by step
Verified Expert Solution
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.
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. is een stereo 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. o It has one constructor with the same set of parameters as its direct superclass. o The constructor body simply calls the corresponding constructor of its superclass properly. [4 marks) GHT o b) It has 2 public methods: The first method setsFreeRule () is for setting the specific field, the Smoke-Free rule. 0 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, as sample program output below. O Colmar 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 [4 marks] O 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started