Question: complet all 3 exercises as 1 java file Exercise 1 Create a file named A7.java. Place all your code in this file. Note: as with

complet all 3 exercises as 1 java file Exercise 1 Create acomplet all 3 exercises as 1 java file

Exercise 1 Create a file named A7.java. Place all your code in this file. Note: as with classes, you can remove public from your interface definition to place it in a file with a different name. Define a class named Point. It should have private field integers x and y. The constructor should take x and y as parameters and assign the input values to x and y. Define getters and setters for x and y in the standard Java format (e.g. getter for x is getX). Define a method with the following signature: public double getMagnitude The magnitude of a point is defined as its distance from the origin. Calculate this value and return it. magnitude = x2 + y2 Exercise 2 Define the Relatable interface as shown in the lecture slides. Modify your Point class to implement this interface. Consider the magnitude of the point as its size and implement the isLargerThan method (as specified in the comments of the interface). 1 Exercise 3 Test your code with this snippet. This will ensure you correctly defined the Relatable types. public static void main(String[] args) { Relatable pl = new Point(1, 2); Relatable p2 = new Point(2, 3); System.out.println(pl.isLarger Than(p2)); }

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!