Do it in C++ (The MyPoint class) Design a class named MyPoint to represent a point with x- and y-coordinates. The class contains:  Two data fields x and y that represent the coordinates.  A no-arg constructor that creates a point (0, 0).  A constructor that constructs a point with specified coordinates.  Two get function for data fields x and y, respectively. A function named distance that returns the distance from this point to another point of the MyPoint Type. Draw the UML diagram the class. Implement the class. Write a test program that creates two points (0, 0) and (10, 30.5) and displays the distance between them.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.2: Providing Class Conversion Capabilities
Problem 6E
icon
Related questions
Question

Do it in C++

(The MyPoint class) Design a class named MyPoint to represent a point with
x- and y-coordinates. The class contains:
 Two data fields x and y that represent the coordinates.
 A no-arg constructor that creates a point (0, 0).
 A constructor that constructs a point with specified coordinates.
 Two get function for data fields x and y, respectively. A function named distance that returns the distance from this point to
another point of the MyPoint Type.
Draw the UML diagram the class. Implement the class. Write a test program that
creates two points (0, 0) and (10, 30.5) and displays the distance between them.
Further create a class named ThreeDPoint to model a point in a three-dimensional
space. Let ThreeDPoint be derived from MyPoint with the following additional
features:
 A data field named z that represents the z-coordinate.
 A no-arg constructor that constructs a point with coordinates (0, 0, 0).
 A constructor that constructs a point with three specified coordinates.
 A constant get function that returns the z value.
 A constant distance (const MyPoint &) function to return the distance
between this point and the other point in the three-dimensional space.

Draw the UML diagram of the ThreeDPoint class. Implement the classes.

Write a test program that creates two points (0, 0, 0) and (10, 30, 25.5) and displays the
distance between them

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr