I need help writing the following pseudocodes for my program: PointTest.cpp file
ID: 3531191 • Letter: I
Question
I need help writing the following pseudocodes for my program:
PointTest.cpp file
#1:
FUNCTION: Run()
// DESCRIPTION
// Tests the implementation of the Point class.
// PSEUDOCODE
// Define x and y as int variables.
// Configure cout so real numbers are displayed in fixed notation with 3 digits after the decimal pt.
// x <- GetInt("Enter point p1 x? ").
// y <- GetInt("Enter point p1 y? ").
// Define and instantiate a Point object named p1 passing x and y as the params to the ctor.
// x <- GetInt("Enter point p2 x? ").
// y <- GetInt("Enter point p2 y? ").
// Define and instantiate a Point object named p2 passing x and y as the params to the ctor.
// Send to cout "The point p1 is " followed by p1.ToString() followed by endl.
// Send to cout "The point p2 is " followed by p2.ToString() followed by endl.
// Send to cout "The distance between the points is " followed by p1.Distance(p2) followed by endl.
// Send to cout "Moving point p1...".
// Call p1.Move(100, 200).
// Send to cout "The point p1 is now at " followed by p1.ToString() followed by endl.
// Send to cout "The distance between the points is " followed by p2.Distance(p1) followed by endl.
// Send to cout "Moving point p2...".
// Call p2.Move(300, 400).
// Send to cout "The point p2 is now at " followed by p2.ToString() followed by endl.
// Send to cout "The distance between the points is " followed by p1.Distance(p2) followed by endl.
Point.cpp File
#1
//--------------------------------------------------------------------------------------------------------------
// FUNCTION: Distance(Point)
//
// DESCRIPTION
// Calculates distance from this Point to pAnotherPoint.
//
// PSEUDOCODE
// deltaX <- GetX() - pAnotherPoint.GetX()
// deltaY <- GetY() - pAnotherPoint.GetY()
// Return the square root of deltaX * deltaX + deltaY * deltaY
//--------------------------------------------------------------------------------------------------------------
???
#2:
//--------------------------------------------------------------------------------------------------------------
// FUNCTION: ToString()
//
// DESCRIPTION
// Returns a string representation of the Point, e.g., if mX is 10 and mY is -130, then this function will
// return the string "(10, -130)".
//
// REMARKS
// The C++ Standard Library stringstream class is a stream class which is similar in functionality to the
// ostream class (the class of the cout object that we use to send output to the output window). The difference
// between a stringstream object and cout is that for the stringstream object, the "output" is sent to a string
// object which is encapsulated within the stringstream object. For example,
//
// stringstream ss; -- ss is a stringstream object which encapsulates a string.
// ss << fixed << setprecision(3); -- ss is configured so real numbers will be formatted in fixed notation
// with 3 digits after the decimal pt.
// ss << "Fred"; -- The string in ss now contains "Fred".
// int x = 123;
// ss << ' ' << x; -- The string in ss now contains "Fred 123".
// double y = 3.14159265828;
// ss << endl << y; -- The string in ss now contains "Fred 123 3.142".
// cout << ss.str(); -- The str() function returns the string, i.e., "Fred 123 3.142".
//
// Ref: http://cplusplus.com/reference/sstream/stringstream
//
// PSEUDOCODE
// Define a stringstream object named ss calling the default ctor.
// Send to ss "(" followed by GetX() followed by ", " followed by GetY() followed by ")".
// Return ss.str().
Explanation / Answer
you want the code in c++ i presume?