Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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 (0, 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) o Three get methods for data fields x, y, and name, respectively o A static method named get o A method named showDetails0 that prints the attributes of a point: its o A method named distance() that returns the distance between any two points that retuns number of created points. coordinates x,and y and its name of the MyPoint type. Use this formula to compute for the distance between two points: distance-(x2-x)2-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: Name: center Second Point Details y-30.5 Name: P1 The distance between the center and P1 32.098

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

6. Have you used solid reasoning in your argument?

Answered: 1 week ago