Question: A java program for OOP course Design a class named MyPoint to represent a point with x and y-coordinates. The class contains: Data fields: o
Design a class named MyPoint to represent a point with x and y-coordinates. The class contains: Data fields: o Private two double data fields x and y that represent the coordinates. o Private String date field name that represents the name of the point (e.g. P1) o Static int data field numberOfCreatedPoints that counts how many points are created from the MyPoint class. Methods o A no-arg constructor that creates a point (O, 0) and its name is center o A constructor that initializes a point with specified coordinates. The constructor method should have the following header public MyPoint(double xCoor, double yCoor, String pointName) Three get methods for data fields x, y, and name, respectively created points. coordinates x,and y and its name of the MyPoint type. o o A static method named o A method named showDetails0 that prints the attributes of a point: its o A method named distance0 that returms the distance between any two points that returns number of Use this formula to compute for the distance between two points: distance-(x2-x2-y1) Write a test program that creates two points (0, 0) and (10, 30.5, P1) and displays number of created points. The program should print the coordinates and name of each point and then displays the distance between them. Here is a sample run: Number of created points is 2 First Point Details: Second Point Details: y 30.5 Name: P1 The dstance between the center and P1 32098
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
