/* * Exercise the 3d point class. */ #include <iostream> #include <string> #include "point3d.h" using namespace std; int main() { // Declare some point objects. Note that each of these // calls the constructor, including the last two. Point3d v(3.7, 6.8, -7.1), w(4.5, 9.1), x(1.3, 7, 10.1), y = 2.4, z; // Print them. cout << "All the points: " << v.tos() << " " << w.tos() << "\n " << x.tos() << " " << y.tos() << " " << z.tos() << endl; // Some random arithmetic. z = w.plus(y).minus(v); cout << w.tos() << " + " << y.tos() << " - " << v.tos() << " =\n " << z.tos() << endl; // And let's try out move. Point3d start(452.12, 99.38, -118.25); Point3d me(start); cout << "Road trip." << endl; cout << " " << me.tos() << endl; for(int i = 1; i <= 5; ++i) { me.move(2.1*i, 4.3*i, 1.2*i); cout << " " << me.tos() << endl; } for(int i = 5; i > 0; --i) { me.move(3.5*i, 4.4, 2.7*i); cout << " " << me.tos() << endl; } cout << "Net distance: " << start.distance(me) << endl; cout << "Volume crossed: " << start.volume(me) << endl; }