Question: Create a new project in BlueJ. Create two new classes in the project, with the following specifications: Class name: City Fields : name (String) population

Create a new project in BlueJ. Create two new classes in the project, with the following specifications:

Class name: City

Fields:

  • name (String)
  • population (long)

1 Constructor: takes parameters with the same name as the fields and uses them to initialize the fields (you will need to use 'this', for example this.name = name).

Methods: Write get-methods (getters) and set methods (setters) for all fields. The getters and setters should be named according to standard Java conventions (getFieldName and setFieldName if the field is named fieldName).

Class name: Point

Fields:

  • x (double)
  • y (double)

Constructors: Write two constructors: one that takes two parameters and initializes the two fields, and one that doesn't take any parameters and sets both fields to 0.

Methods: Write get-methods (getters) and set methods (setters) for all fields. Name the getters and setters according to Java conventions as described above.

Save the project as a jar file to submit.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!