Monday 21 January 2019

Fidelity Questions: 

Problem 1:
Simple Question based on Inheritance and methods related to java.lang.Math class.

Description:
You have to implement 2 classes named Point2D and Point3D.
The purpose of the two classes is to find out the distance between two 2D points and two 3D points respectively.
The Structure of the classes should be as follows:

Point2D:

-- Two instance level properties x and y which depicts the x and y coordinate of a point in two-dimensional space.
--A parameterized constructor which takes two parameters and initializes its instance variables with it.
--A method double distanceFrom(Point2D p) which returns the distance between two points in 2-Dimensional space.
--A method void printDistance(double d) which outputs the distance in a single digit format of the largest number than it if the distance is not an integer literal.


Point3D:

--The class extends Point2D
-- Three instance level properties x, y, and z which depicts the x, y and z coordinate of a point in three-dimensional space.
--A parameterized constructor which takes three parameters and initializes its instance variables with it.
--A method double distanceFrom(Point3D p) which returns the distance between two points in 3-Dimensional space.
--A method void printDistance(double d) which outputs the distance in a single digit format of the largest number than it if the distance is not an integer literal.

Implementation: