Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

B5. (15 marks) Students should finish reading the whole question first, before answering. Based on the class BCity in the last question, write a new

image text in transcribed

B5. (15 marks) 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. Co 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. The constructor body simply calls the corresponding constructor of its superclass properly [4 marks/ b) It has 2 public methods: o The first method setsFreeRule () is for setting the specific field, the "Smoke-Free" rule. o The method accepts one input argument rule of string type and has no return. o 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 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/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions