plete. Stuck in my

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Complete. Stuck in my

 

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;
Checking the Point3D class
Checking: + Data members defined.
Expected: + Data members defined.
Default constructor defined->const Point3D pt;
Expected: Default constructor defined->const Point3D pt;
Point3D x: 0
Expected: 0.0
Point3D y: 0
Expected: 0.0
Point3D z: 0
Expected: 0.0
Working constructor defined-> Point3D pt(4.92,5.45,8.68)
Expected: Working constructor defined-> Point3D pt (4.92,5.45,8.68)
Point3D x: 4.92
Expected: 4.92
Point3D y: 5.45
Expected: 5.45
Point3D z: 8.68
Expected: 8.68
Accessors getX(), getY(), getZ() NOT defined.
Expected: Accessors getX(), getY(), getZ() defined.
Point3D x: accessor getX() not defined correctly.
Expected: 9.7
Point3D y: accessor getY() not defined correctly.
Expected: 5.19
Point3D z: accessor getY() not defined correctly.
Expected: 6.94
distance() member function NOT is defined.
Expected: distance() member function is defined.
Point3D(0,0,0).distance(Point3D(4.92,5.45,8.68)): not defined
Expected: 11.3689
Point3D(4.92,5.45,8.68). distance (Point3D(9.70,5.19,6.94)): not defined
Expected: 5.09349
Point3D(9.70,5.19,6.94).distance (Point3D()): not defined
Expected: 13.0073
Transcribed Image Text:Checking the Point3D class Checking: + Data members defined. Expected: + Data members defined. Default constructor defined->const Point3D pt; Expected: Default constructor defined->const Point3D pt; Point3D x: 0 Expected: 0.0 Point3D y: 0 Expected: 0.0 Point3D z: 0 Expected: 0.0 Working constructor defined-> Point3D pt(4.92,5.45,8.68) Expected: Working constructor defined-> Point3D pt (4.92,5.45,8.68) Point3D x: 4.92 Expected: 4.92 Point3D y: 5.45 Expected: 5.45 Point3D z: 8.68 Expected: 8.68 Accessors getX(), getY(), getZ() NOT defined. Expected: Accessors getX(), getY(), getZ() defined. Point3D x: accessor getX() not defined correctly. Expected: 9.7 Point3D y: accessor getY() not defined correctly. Expected: 5.19 Point3D z: accessor getY() not defined correctly. Expected: 6.94 distance() member function NOT is defined. Expected: distance() member function is defined. Point3D(0,0,0).distance(Point3D(4.92,5.45,8.68)): not defined Expected: 11.3689 Point3D(4.92,5.45,8.68). distance (Point3D(9.70,5.19,6.94)): not defined Expected: 5.09349 Point3D(9.70,5.19,6.94).distance (Point3D()): not defined Expected: 13.0073
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY