Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

B3. (15 marks) = public class City { // modelling City protected String cN; // name of city private int cP; // population of city

image text in transcribed

B3. (15 marks) = public class City { // modelling City protected String cN; // name of city private int cP; // population of city static final int P_BIGCITY = 3;//bigcity population: 3 million City (String cn, int c) { // TO BE COMPLETED } public void setCP (int p) { CP = p; } int getCP() { return cP; } } Only consider the programme code given above and the comment information, answer the following questions. Co follow a) Draw the UML class diagram, only related to the given program code above. (8 marks) b) To complete the given constructor, write only two statements for the body of this given constructor, which: o assigns the field of city name with the value of the right input parameter using assignment operator, and then o sets the field of population with the value of the right input parameter using proper method, without using assignment operator. [3 marks] coronation c) Write an overloading constructor, which accepts only one argument for setting the name field. The body of this constructor properly calls its another constructor with the input parameter as the name and the class constant as the population of the city. This constructor is for the usage within the same package and all its subclasses. [4 marks/ HKO ity Cathe

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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

What did you like and dislike about your last job?

Answered: 1 week ago