Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA public class City { // modelling a city protected String cName; // name of the city private int cArea; // area of the city

JAVA

image text in transcribed

image text in transcribed

image text in transcribed

public class City { // modelling a city protected String cName; // name of the city private int cArea; // area of the city public City (String cName) { // TO BE COMPLETED } void setc (String n) { cName = n; } void setc (int a) { cArea = a; } public int geta () { return cArea; } } 3. (20 marks) Based on what we have learnt in our course with our course materials, answer the following questions. Based on the given class City above (in question 2), write a Java application program, named SmartCity. The main purpose of this new class is to further introduce a class of cities which are regarded as smart in terms of enough smart facilities available. The class of this Java program includes: o a) o The class declaration, to declare this class which is a public subclass of the given class City An instance field, named smart F of type int, representing the total number of smart facilities in the city. O A class field, named VSMART_LEVEL of type int, which is also a public constant having value 2xyz, for checking if the city is very smart. A city is regarded as very smart if its total number of smart facilities is larger than this V SMART_LEVEL. * Use the last 3 digits of your student ID number to replace xyz in the value 2xyz. [5 marks] b) One constructor, accepting two arguments: the first argument is for setting the name and the second is for setting the number of smart facilities. This constructor is expected to be used only within its own package and all its subclasses. The body of this constructor: first calls the corresponding one-argument constructor of its superclass with the right input parameter, then properly sets another field with the right input parameter. [5 marks] O O O c) A method, named dispSC (), accepts no input argument and return no value. This method simply displays the proper information of the city on console, based on whether the city is very smart or not, as the format below: o

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

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions