code should be established in a functional way

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

So form code should be established in a functional way and outcome also. 

 

Implement the class Point3D. Put the class definition in the header p1.h and the implementation in the p1.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 Point3D to the origin (0, 0, 0), while the working constructor supplies values for x, y, and 2:
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 returns the distance between the current Point3D (the implicit parameter which will be
the left-hand side of an expression) and a second Point3D passed as an explicit parameter (which will be the right-hand-side of the
expression). Here is the distance formula for a 3D point:
(x₁-x2)² + (y₁ - y₂)² + (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. If your code fails to compile, comment out both the definition and the implementation of the feature that fails.
Exam C++ Quick Reference
1.cpp
1
#include <math>
2
#include <string>
3 #include <iostream>
4 #include <sstream>
5 #include <iomanip>
6
7 #include "p1.h"
8
9 // Implement your member functions in this file
SENAZAS=28=AAZAAZA
10 Point3D Point3D()
11 {
12
13 }
14
17
15 Point3D:: Point3D(double xx, double yy, double zz)
16 {
18
19
29
21
using namespace std;
24
23 {
22 double Point3D :: getX()
return x;
26
25 }
29
}
30
31
27 double Point3D :: getY()
34
{
x=y=z= 0;
}
33 {
X = XX;
y = yy:
z = 22;
32 double Point3D::get()
35 }
return y;
return z;
Transcribed Image Text:Implement the class Point3D. Put the class definition in the header p1.h and the implementation in the p1.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 Point3D to the origin (0, 0, 0), while the working constructor supplies values for x, y, and 2: 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 returns the distance between the current Point3D (the implicit parameter which will be the left-hand side of an expression) and a second Point3D passed as an explicit parameter (which will be the right-hand-side of the expression). Here is the distance formula for a 3D point: (x₁-x2)² + (y₁ - y₂)² + (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. If your code fails to compile, comment out both the definition and the implementation of the feature that fails. Exam C++ Quick Reference 1.cpp 1 #include <math> 2 #include <string> 3 #include <iostream> 4 #include <sstream> 5 #include <iomanip> 6 7 #include "p1.h" 8 9 // Implement your member functions in this file SENAZAS=28=AAZAAZA 10 Point3D Point3D() 11 { 12 13 } 14 17 15 Point3D:: Point3D(double xx, double yy, double zz) 16 { 18 19 29 21 using namespace std; 24 23 { 22 double Point3D :: getX() return x; 26 25 } 29 } 30 31 27 double Point3D :: getY() 34 { x=y=z= 0; } 33 { X = XX; y = yy: z = 22; 32 double Point3D::get() 35 } return y; return z;
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
ADT and Class
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education