Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class to store and manipulate a point in 3-dimensional (3D) space (the point3d class). A 3D point has three coordinates: (x, y, z).

Write a class to store and manipulate a point in 3-dimensional (3D) space (the point3d class). A 3D point has three coordinates: (x, y, z). You will need files such as point3d.h, point3d.cpp, and main.cpp

Program Specification:Your class should be called point3dThe coordinates should be of type doubleAll data members should be private.Public member functions should include the following:o A default constructor in which the point3d object is initialized to (0.1, 0.1, 0.1) o A parametrized constructor in which the user specifies the initial coordinates to use. oGetters (get_x, get_y, and get_z) which return each of the coordinates.oSetters (set_x, set_y, and set_z) which can be used to change each of the coordinates.oshift_x: which shifts the points x coordinate by the value of its one parameteroshift_y: which shifts the points y coordinate by the value of its one parameteroshift_z: which shifts the points z coordinate by the value of its one parameteroshift: which takes three parameters (x, y, z) and shifts the point by that amountoreset: which resets the points coordinates back to a default value, as though it has just been created by a default constructor. This function should have an empty parameter listoscale: which takes a double parameter. If parameter has a positive value, the coordinates are multiplied by that value. If parameter has a negative value, the coordinates are divided by that value. For example, if myPoint is storing (6,2, 8), the calls myPoint.scale(2.0) and myPoint(-2.0) should give coordinates (12,4,16) and (3,1,4) respectivelyAdd the following overloaded functions as nonmember functions: + , == , =, and << , as nonmember functions. Additional Program SpecificationAll files (.h and .cpp) should include a comment at the top of the file, with your name, and a brief description of what the file is for. (e.g., point3d.h might say "Class definition for point3d, which stores a point in 3-dimensional space.")2 All functions should be properly documentedin the header file, including PRECONDITIONS and POSTCONDITIONS (with those words). You do not need to include this in the function implementation as well. Your code should include appropriate comments, identifying variables (if needed) and describing what each section of code is doing. All identifiers (function and variable names) should be meaningful. Your code should have proper indentation and spacing. Make your functions minimal do not pass in variables that you do not need.Any objectsto be passed as parameters should be passed by reference. Make sure to declare object inputs as const where appropriate.Functions which do not modify the object should be const. Main.cppYour output should indicate what you expect. For example, the part of your testing program that tests the default constructor might look something like this:point3d p; cout << "Coordinates of p (should be (0,0,0)): " << p << endl; o Note that you do not need to check every possible input to ful ly exercise your code. Feel free to ask for clarification; main point is to get you thinking about how to test your code.o Your testing program should include main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

Describe forecasting requirements.

Answered: 1 week ago

Question

=+90 percent of all oil refineries) into several smaller companies

Answered: 1 week ago