Create a Point3D class to represent a point that has coordinates in three dimensions labeled x, y
Question:
Create a Point3D class to represent a point that has coordinates in three dimensions labeled x, y and z. You will then use the class to perform some calculations on an array of these points. You need to draw a UML diagram for the class (Point3D) and then implement the class.
The Point3D class will have the following state and functionality:
Three data fields, x, y and z, of type double, represent the point’s coordinates
Additional data field, colour, of type String, represents the point's color
A no-arg constructor creates a point at position (0, 0, 0) and "Red" colour.
Another constructor creates a point with specified coordinates and colour.
A getter method is provided for each of the fields.
An accessor method named distance returns the distance between the current point and another point passed as an argument.
The distance method is overloaded to accept the coordinates of the other point.
Write a TestPoint3D class that will have a main method, and perhaps other methods as required by good design, to test your Point3D class. It will not have user input because this class will stand as a record of the tests you have applied and you will be able to run it whenever you alter your Point3D class. For the TestPoint3D class you will need to do the following:
Test the basic state and functionality of the Point3D class. Each of the constructors and each of the methods should be tested using some different data values. The test code should display values so that they can be checked.
Write some code to create an array of at least 10 Point3D objects.
Write a method max, which will accept the array of points as an argument, and will calculate and display the maximum distance between the points in the array, and the pair of points for which the maximum occurs.
Write a method min, which will accept the array of points as an argument, and will calculate and display the minimum distance between the points in the array, and the pair of points for which the minimum occurs.
Microsoft Visual C# An Introduction to Object-Oriented Programming
ISBN: 978-1337102100
7th edition
Authors: Joyce Farrell