Implement the class Point3D. Put the class definition in the header pl.h and the implementation in the pl.cpp file. You may not have any inline functions defined in the header file. Use the file xercise.cpp to check if your implementation is syntactically correct. • The class has three data members: X, y, and z, which are double. • The default constructor initializes the Point30 to the origin (0, 0, 0), while the working constructor supplies values for X, y, and z: all doubles in that order. • reate accessors getX(), getY() and getZ(). There are no mutators. (The class is inomutable) • Write a member function distance() that retuns the distance between the current Point30 (the implicit parameter which will be the left-hand side of an expression) and a second Point30 passed as an explicit parameter (which will be the right-hand-side of the expression). Here is the distance formula for a 3D point: (X1 -X2 )+ (yı -y2 )'+ (zı -z2 )' You must both define and implement a feature for the tests to run. For instance, if you define getX() but fail to implement it, then yor code will not compile. If your code fails to compile, comment out both the definition and the implementation of the feature that fails.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 15PE
icon
Related questions
Question

I'm stuck on this problem

Checking the Point30 class
Checking: + Data nombers defined.
Expected: + Data members defined.
Default constructor defined->const Point30 pt;
Expected: Default constructor defined->const Point30 pt;
Point30 x: 0
Expected: 0.0
Point30 y: 0
Expected: 0.0
Point30 z: 0
Expected: 0.0
Working constructor defined-> Point30 pt(4.92,5.45,8.68)
Expected: Working constructor defined-> Point30 pt(4.92,5.45,8.68)
Point30 x: 4.92
Expected: 4.92
Point30 y: 5.45
Expected: 5.45
Point30 z: 8.68
Expected: 8.68
Accessors getX(), getY(), getz() NOT defined.
Expected: Accessors getX(), getY), getZ() defined.
Point30 x: accessor getX() not defined correctly.
Expected: 9.7
Point30 y: accessor getY() not defined correctly.
Expected: 5.19
Point30 z: accessor getY() not defined correctly.
Expected: 6.94
distance() member function NOT is defined.
Expected: distance() member function is defined.
Point30(0,0,0).distance(Point30(4.92,5.45,8.68)): not defined
Expected: 11.3689
Point30(4.92,5.45,8.68).distance(Point30(9.70,5.19,6.94)): not defined
Expected: 5.09349
Point30(9.70,5.19,6.94).distance(Point30()): not defined
Expected: 13.0073
Transcribed Image Text:Checking the Point30 class Checking: + Data nombers defined. Expected: + Data members defined. Default constructor defined->const Point30 pt; Expected: Default constructor defined->const Point30 pt; Point30 x: 0 Expected: 0.0 Point30 y: 0 Expected: 0.0 Point30 z: 0 Expected: 0.0 Working constructor defined-> Point30 pt(4.92,5.45,8.68) Expected: Working constructor defined-> Point30 pt(4.92,5.45,8.68) Point30 x: 4.92 Expected: 4.92 Point30 y: 5.45 Expected: 5.45 Point30 z: 8.68 Expected: 8.68 Accessors getX(), getY(), getz() NOT defined. Expected: Accessors getX(), getY), getZ() defined. Point30 x: accessor getX() not defined correctly. Expected: 9.7 Point30 y: accessor getY() not defined correctly. Expected: 5.19 Point30 z: accessor getY() not defined correctly. Expected: 6.94 distance() member function NOT is defined. Expected: distance() member function is defined. Point30(0,0,0).distance(Point30(4.92,5.45,8.68)): not defined Expected: 11.3689 Point30(4.92,5.45,8.68).distance(Point30(9.70,5.19,6.94)): not defined Expected: 5.09349 Point30(9.70,5.19,6.94).distance(Point30()): not defined Expected: 13.0073
Implement the class Point30. Put the class definition in the header pl.h and the implementation in the pl.cpp file. You may not have any
inline functions defined in the header file. Use the file xercise.cpp to check if your implementation is syntactically correct.
• The class has three data members: X, y, and z, which are double.
• The default constructor initializes the Point30 to the origin (0, 0, 0), while the working constructor supplies values for x, y, and z:
all doubles in that order.
• Create accessors getX(), getY() and getZ(). There are no mutators. (The class is immutable)
• Write a member function distance() that retums the distance between the current Point30 (the implicit parameter which will be
the left-hand side of an expression) and a second Point30 passad as an explicit parameter (which will be the right-hand-side of the
expression). Here is the distance formula for a 3D point:
(Xi -x2 Ý + (yı -y2 )'+ (zı -z2 )
You must both define and implement a feature for the tests to run. For instance, if you define getX() but fail to implement it, then your
code will not compile. Ifyour code fails to compile, comment out both the definition and the implementation of the feature that fails.
Exam C++ Quick Reference
1.cpp
1 sinclude camath
2 sinclude <string
sinclude <iostrean
4 sinclude <sstream
sinclude <iomanip>
6 using namespace std;
sinclude "pl.h"
8
9 I/ Implenent your member functions in this file
Point30 :: Point3D()
10
11
X = y=z = 0;
}
12
13
14
Point30 :: Point3D(double xx, double yy, double zz)
{
15
16
17
X = XX;
18
y = yy:
Z = z2;
19
20
}
21
22
double Point30 :: getX()
23
24
return x;
25
26
double Point30 :: getY()
{
return y:
27
28
29
30
31
32
double Point30 :: get2()
33
34
return z;
35 )
Transcribed Image Text:Implement the class Point30. Put the class definition in the header pl.h and the implementation in the pl.cpp file. You may not have any inline functions defined in the header file. Use the file xercise.cpp to check if your implementation is syntactically correct. • The class has three data members: X, y, and z, which are double. • The default constructor initializes the Point30 to the origin (0, 0, 0), while the working constructor supplies values for x, y, and z: all doubles in that order. • Create accessors getX(), getY() and getZ(). There are no mutators. (The class is immutable) • Write a member function distance() that retums the distance between the current Point30 (the implicit parameter which will be the left-hand side of an expression) and a second Point30 passad as an explicit parameter (which will be the right-hand-side of the expression). Here is the distance formula for a 3D point: (Xi -x2 Ý + (yı -y2 )'+ (zı -z2 ) You must both define and implement a feature for the tests to run. For instance, if you define getX() but fail to implement it, then your code will not compile. Ifyour code fails to compile, comment out both the definition and the implementation of the feature that fails. Exam C++ Quick Reference 1.cpp 1 sinclude camath 2 sinclude <string sinclude <iostrean 4 sinclude <sstream sinclude <iomanip> 6 using namespace std; sinclude "pl.h" 8 9 I/ Implenent your member functions in this file Point30 :: Point3D() 10 11 X = y=z = 0; } 12 13 14 Point30 :: Point3D(double xx, double yy, double zz) { 15 16 17 X = XX; 18 y = yy: Z = z2; 19 20 } 21 22 double Point30 :: getX() 23 24 return x; 25 26 double Point30 :: getY() { return y: 27 28 29 30 31 32 double Point30 :: get2() 33 34 return z; 35 )
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Developing computer interface
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++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning