Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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; } Based on program cod a given class City above, answer the following questions. a) Draw the class diagram, only related to the given marks/ Comune no PRESENT PACA , b) Only related to the given program code above, answer the following questions: i. Write a statement to only declare a variable of the class above, with your surna as the variable name ii. Write a statement to create a new object of the class with your surname the name of the city, and assign it to the above variable. iii. Write a statement to declare a variable, and assign it wit the area value of the object created above iv. To complete the given constructor, only write two statements for the body of the one-argument constructor, which: assigns the field of city name with the value of the input parameter, and then sets the field of arca with value of your student ID number, using assignment operator OOP c) Write an overloading constructor, which accepts two arguments for setting the corresponding fields. The body of this constructor first properly calls another constructor, and then sets another field without using assignment operator. This constructor is for internal usage, within the class itself. 15 marks]

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions