SlideShare a Scribd company logo
1 of 16
Lab08/Lab08.cppLab08/Lab08.cpp//***********************
*****************************************************
**********************************
// FILE: Lab08.cpp
//
// DESCRIPTION: Contains the main() function. Instantiates a P
ointTest object which tests the Point class.
//
// AUTHORS: your-name (your-email-address)
// your-partner's-name (your-partners-email-address)
//
// COURSE: CSE100 Principles of Programming with C++, F
all 2015
//
// LAB INFO: Lab 8 Date/Time: your-lab-date-and-
time TA: your-lab-ta
//-------------------------------------------------------------------------
-------------------------------------
// TESTING:
//
// TEST CASE 1:
// ------------
// TEST CASE INPUT DATA:
// Point p1 x = 11
// Point p1 y = 22
// Point p2 x = -33
// Point p2 y = -44
//
// EXPECTED OUTPUT GIVEN THE INPUT:
// The point p1 is (11, 22)
// The point p2 is (-33, -44)
// The distance between the points is 79.322
// Moving point p1...The point p1 is now at (100, 200)
// The distance between the points is 277.894
// Moving point p2...The point p2 is now at (300, 400)
// The distance between the points is 282.843
//
// OBSERVED OUTPUT:
// Document the output from your program when you perform th
is test case
//
// TEST CASE RESULT: Document PASS or FAIL
//
// TEST CASE 2:
// ------------
// TEST CASE INPUT DATA:
// Point p1 x = ???
// Point p1 y = ???
// Point p2 x = ???
// Point p2 y = ???
//
// EXPECTED OUTPUT GIVEN THE INPUT:
// ??? Document the expected output ???
//
// OBSERVED OUTPUT:
// ??? Document the output from your program when you perfor
m this test case ???
//
// TEST CASE RESULT: ??? Document PASS or FAIL ???
//***************************************************
*****************************************************
******
#include"PointTest.hpp"
//-------------------------------------------------------------------------
-------------------------------------
// FUNCTION: main()
//
// DESCRIPTION
// Starting point for the program.
//
// PSEUDOCODE
// Define a PointTest object named pointTest calling the default
ctor.
// Call run() on the pointTest object.
// Return 0.
//-------------------------------------------------------------------------
-------------------------------------
???
Lab08/Point.cppLab08/Point.cpp//************************
*****************************************************
*********************************
// FILE: Point.cpp
//
// DESCRIPTION: Implementation of the Point class. See Point.
hpp for the class declaration.
//
// AUTHORS: your-name (your-email-address)
// your-partner's-name (your-partners-email-address)
//
// COURSE: CSE100 Principles of Programming with C++, F
all 2015
//
// LAB INFO: Lab 8 Date/Time: your-lab-date-and-
time TA: your-lab-ta
//***************************************************
*****************************************************
******
#include<cmath>// For sqrt()
#include<sstream>// For stringstream class
#include"Point.hpp"// For Point class declaration
//-------------------------------------------------------------------------
-------------------------------------
// CTOR: Point()
//
// DESCRIPTION
// Default constructor. Initializes the point to be at the origin (0,
0).
//
// PSEUDOCODE
// Call init() and pass 0 and 0 as the parameters.
//-------------------------------------------------------------------------
-------------------------------------
???
//-------------------------------------------------------------------------
-------------------------------------
// CTOR: Point(int, int)
//
// DESCRIPTION
// Secondary constructor. Initializes the mX and mY data memb
ers to the input params.
//
// PSEUDOCODE
// Call init() and pass pInitX and pInitY as the params.
//-------------------------------------------------------------------------
-------------------------------------
???
//-------------------------------------------------------------------------
-------------------------------------
// 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
//-------------------------------------------------------------------------
-------------------------------------
???
//-------------------------------------------------------------------------
-------------------------------------
// FUNCTION: getX()
//
// DESCRIPTION
// Accessor function for the mX data member.
//
// PSEUDOCODE
// Return mX.
//-------------------------------------------------------------------------
-------------------------------------
???
//-------------------------------------------------------------------------
-------------------------------------
// FUNCTION: getY()
//
// DESCRIPTION
// Accessor function for the mY data member.
//
// PSEUDOCODE
// Return mY
//-------------------------------------------------------------------------
-------------------------------------
???
//-------------------------------------------------------------------------
-------------------------------------
// FUNCTION: init(int, int)
//
// DESCRIPTION
// Initializes mX and mY to pInitX and pInitY.
//
// PSEUDOCODE
// Call setX() and pass pInitX as the parameter
// Call setY() and pass pInitY as the parameter
//-------------------------------------------------------------------------
-------------------------------------
???
//-------------------------------------------------------------------------
-------------------------------------
// FUNCTION: move(int, int)
//
// DESCRIPTIONm
// Moves the point to the new (x, y) coordinates specified by the
input params.
//
// PSEUDOCODE
// Call init() passing pNewX and pNewY as the params
//-------------------------------------------------------------------------
-------------------------------------
???
//-------------------------------------------------------------------------
-------------------------------------
// FUNCTION: setX(int)
//
// DESCRIPTION
// Mutator function for the mX data member.
//
// PSEUDOCODE
// mX <- pNewX
//-------------------------------------------------------------------------
-------------------------------------
???
//-------------------------------------------------------------------------
-------------------------------------
// FUNCTION: setY(int)
//
// DESCRIPTION
// Mutator function for the mY data member.
//
// PSEUDOCODE
// mY <- pNewY
//-------------------------------------------------------------------------
-------------------------------------
???
//-------------------------------------------------------------------------
-------------------------------------
// 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 stringstr
eam object, the "output" is sent to a string
// object which is encapsulated within the stringstream object. F
or example,
//
// stringstream sout; --
sout is a stringstream object which encapsulates a string.
// sout << fixed << setprecision(3); --
sout is configured so real numbers will be formatted in fixed no
tation
// with 3 digits after the decimal pt.
// sout << "Fred"; --
The string in sout now contains "Fred".
// int x = 123;
// sout << ' ' << x; --
The string in sout now contains "Fred 123".
// double y = 3.14159265828;
// sout << endl << y; --
The string in sout now contains "Fred 123n3.142".
// cout << sout.str(); --
The str() function returns the string, i.e., "Fred 123n3.142".
//
// Ref: http://cplusplus.com/reference/sstream/stringstream
//
// PSEUDOCODE
// Define a stringstream object named sout calling the default ct
or.
// Send to sout "(" followed by the return value from getX() foll
owed by ", " followed by getY() followed by ")".
// Return sout.str().
//-------------------------------------------------------------------------
-------------------------------------
???
Lab08/Point.hpp
//***************************************************
*****************************************************
******
// FILE: Point.hpp
//
// DESCRIPTION: Declares a class to represent a point in the
Cartesian plane. A point is represented by an
// (x, y) coordinate, where both x and y are integers.
//
// AUTHORS: your-name (your-email-address)
// your-partner's-name (your-partners-email-address)
//
// COURSE: CSE100 Principles of Programming with C++,
Fall 2015
//
// LAB INFO: Lab 8 Date/Time: your-lab-date-and-time
TA: your-lab-ta
//***************************************************
*****************************************************
******
#ifndef POINT_HPP // This line, the line below it, and the
#endif form what is called a preprocessor guard.
#define POINT_HPP // Preprocessor guards are a hack to
ensure a header file is not included multiple times.
#include <string> // For string class
using namespace std;
class Point {
public:
Point(); // Default constructor
Point(int pInitX, int pInitY); // Second constructor
double distance(Point pAnotherPoint); // Calculates
distance from this Point to pAnotherPoint
int getX(); // Accessor function for mX
data member
int getY(); // Accessor function for mY
data member
void move(int pNewX, int pNewY); // Moves the point
to a new coordinate
void setX(int pNewX); // Mutator function for
mX data member
void setY(int pNewY); // Mutator function for
mY data member
string toString(); // Returns a string
representation of the Point
private:
void init(int pInitX, int pInitY); // Initializes mX and
mY to the params pInitX and pInitY
int mX; // The x coordinate of the
Point
int mY; // The y coordinate of the
Point
};
#endif // POINT_HPP
Lab08/PointTest.cppLab08/PointTest.cpp//*****************
*****************************************************
****************************************
// FILE: PointTest.cpp
//
// DESCRIPTION: Implementation of the PointTest class. See P
ointTest.hpp for more info.
//
// AUTHORS: your-name (your-email-address)
// your-partner's-name (your-partners-email-address)
//
// COURSE: CSE100 Principles of Programming with C++, F
all 2015
//
// LAB INFO: Lab 8 Date/Time: your-lab-date-and-
time TA: your-lab-ta
//***************************************************
*****************************************************
******
#include<iomanip>// For setprecision()
#include<iostream>// For cout, endl, fixed
#include"PointTest.hpp"// For the PointTest class declaration
#include"Point.hpp"// For the Point class declaration
usingnamespace std;
//-------------------------------------------------------------------------
-------------------------------------
// FUNCTION: getInt()
//
// DESCRIPTION
// Display a prompt and read a number (as an int) from the keyb
oard. Return the number.
//-------------------------------------------------------------------------
-------------------------------------
int getInt(string pPrompt)
{
cout << pPrompt;
int n;
cin >> n;
return n;
}
//-------------------------------------------------------------------------
-------------------------------------
// CTOR: PointTest()
//
// DESCRIPTION
// Default constructor. Does nothing.
//
// REMARKS
// Every class must have at least one ctor, because when an obje
ct is instantiated, a ctor must be called. If
// there are no data members to initialize, then we just provide a
default ctor that does nothing.
//-------------------------------------------------------------------------
-------------------------------------
PointTest::PointTest()
{
}
//-------------------------------------------------------------------------
-------------------------------------
// 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 notatio
n 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() foll
owed by endl.
// Send to cout "The point p2 is " followed by p2.toString() foll
owed by endl.
// Send to cout "The distance between the points is " followed b
y 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.toStrin
g() followed by endl.
// Send to cout "The distance between the points is " followed b
y 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.toStrin
g() followed by endl.
// Send to cout "The distance between the points is " followed b
y p1.distance(p2) followed by endl.
//-------------------------------------------------------------------------
-------------------------------------
???
Lab08/PointTest.hpp
//***************************************************
*****************************************************
******
// FILE: PointTest.hpp
//
// DESCRIPTION: Declares a class that will be used to test the
Point class.
//
// AUTHORS: your-name (your-email-address)
// your-partner's-name (your-partners-email-address)
//
// COURSE: CSE100 Principles of Programming with C++,
Fall 2015
//
// LAB INFO: Lab 8 Date/Time: your-lab-date-and-time
TA: your-lab-ta
//***************************************************
*****************************************************
******
#ifndef POINTTEST_HPP
#define POINTTEST_HPP
// Class declaration for a class named PointTest. The class only
has one constructor, the default constructor.
// The run() function is called to perform the testing of the Point
class.
// See the PointTest UML class diagram in the lab project
document.
???
#endif
Lab08Lab08.cppLab08Lab08.cpp.docx

More Related Content

Similar to Lab08Lab08.cppLab08Lab08.cpp.docx

6Modify the bfs.java program (Listing A) to find the minimu.docx
6Modify the bfs.java program (Listing  A) to find the minimu.docx6Modify the bfs.java program (Listing  A) to find the minimu.docx
6Modify the bfs.java program (Listing A) to find the minimu.docxevonnehoggarth79783
 
PQTimer.java A simple driver program to run timing t.docx
  PQTimer.java     A simple driver program to run timing t.docx  PQTimer.java     A simple driver program to run timing t.docx
PQTimer.java A simple driver program to run timing t.docxjoyjonna282
 
STACK IMPLEMENTATION USING SINGLY LINKED LIST
STACK IMPLEMENTATION USING SINGLY LINKED LISTSTACK IMPLEMENTATION USING SINGLY LINKED LIST
STACK IMPLEMENTATION USING SINGLY LINKED LISTEr. Ganesh Ram Suwal
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfARCHANASTOREKOTA
 

Similar to Lab08Lab08.cppLab08Lab08.cpp.docx (7)

6Modify the bfs.java program (Listing A) to find the minimu.docx
6Modify the bfs.java program (Listing  A) to find the minimu.docx6Modify the bfs.java program (Listing  A) to find the minimu.docx
6Modify the bfs.java program (Listing A) to find the minimu.docx
 
Casnewb
CasnewbCasnewb
Casnewb
 
Quiz using C++
Quiz using C++Quiz using C++
Quiz using C++
 
Stack, queue and hashing
Stack, queue and hashingStack, queue and hashing
Stack, queue and hashing
 
PQTimer.java A simple driver program to run timing t.docx
  PQTimer.java     A simple driver program to run timing t.docx  PQTimer.java     A simple driver program to run timing t.docx
PQTimer.java A simple driver program to run timing t.docx
 
STACK IMPLEMENTATION USING SINGLY LINKED LIST
STACK IMPLEMENTATION USING SINGLY LINKED LISTSTACK IMPLEMENTATION USING SINGLY LINKED LIST
STACK IMPLEMENTATION USING SINGLY LINKED LIST
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
 

More from DIPESH30

please write a short essay to address the following questions. Lengt.docx
please write a short essay to address the following questions. Lengt.docxplease write a short essay to address the following questions. Lengt.docx
please write a short essay to address the following questions. Lengt.docxDIPESH30
 
please write a diary entry from the perspective of a French Revoluti.docx
please write a diary entry from the perspective of a French Revoluti.docxplease write a diary entry from the perspective of a French Revoluti.docx
please write a diary entry from the perspective of a French Revoluti.docxDIPESH30
 
Please write the definition for these words and provide .docx
Please write the definition for these words and provide .docxPlease write the definition for these words and provide .docx
Please write the definition for these words and provide .docxDIPESH30
 
Please view the filmThomas A. Edison Father of Invention, A .docx
Please view the filmThomas A. Edison Father of Invention, A .docxPlease view the filmThomas A. Edison Father of Invention, A .docx
Please view the filmThomas A. Edison Father of Invention, A .docxDIPESH30
 
Please watch the clip from the movie The Break Up.  Then reflect w.docx
Please watch the clip from the movie The Break Up.  Then reflect w.docxPlease watch the clip from the movie The Break Up.  Then reflect w.docx
Please watch the clip from the movie The Break Up.  Then reflect w.docxDIPESH30
 
please write a report on Social Media and ERP SystemReport should.docx
please write a report on Social Media and ERP SystemReport should.docxplease write a report on Social Media and ERP SystemReport should.docx
please write a report on Social Media and ERP SystemReport should.docxDIPESH30
 
Please write 200 wordsHow has the healthcare delivery system chang.docx
Please write 200 wordsHow has the healthcare delivery system chang.docxPlease write 200 wordsHow has the healthcare delivery system chang.docx
Please write 200 wordsHow has the healthcare delivery system chang.docxDIPESH30
 
Please view the documentary on Typhoid Mary at httpswww..docx
Please view the documentary on Typhoid Mary at httpswww..docxPlease view the documentary on Typhoid Mary at httpswww..docx
Please view the documentary on Typhoid Mary at httpswww..docxDIPESH30
 
Please use the two attachments posted to complete work.  Detailed in.docx
Please use the two attachments posted to complete work.  Detailed in.docxPlease use the two attachments posted to complete work.  Detailed in.docx
Please use the two attachments posted to complete work.  Detailed in.docxDIPESH30
 
Please use the sources in the outline (see photos)The research.docx
Please use the sources in the outline (see photos)The research.docxPlease use the sources in the outline (see photos)The research.docx
Please use the sources in the outline (see photos)The research.docxDIPESH30
 
Please submit a minimum of five (5) detailed and discussion-provokin.docx
Please submit a minimum of five (5) detailed and discussion-provokin.docxPlease submit a minimum of five (5) detailed and discussion-provokin.docx
Please submit a minimum of five (5) detailed and discussion-provokin.docxDIPESH30
 
Please think about the various learning activities you engaged in du.docx
Please think about the various learning activities you engaged in du.docxPlease think about the various learning activities you engaged in du.docx
Please think about the various learning activities you engaged in du.docxDIPESH30
 
Please type out the question and answer it underneath. Each question.docx
Please type out the question and answer it underneath. Each question.docxPlease type out the question and answer it underneath. Each question.docx
Please type out the question and answer it underneath. Each question.docxDIPESH30
 
Please use the following technique-Outline the legal issues t.docx
Please use the following technique-Outline the legal issues t.docxPlease use the following technique-Outline the legal issues t.docx
Please use the following technique-Outline the legal issues t.docxDIPESH30
 
Please use from these stratagies This homework will be to copyies .docx
Please use from these stratagies This homework will be to copyies .docxPlease use from these stratagies This homework will be to copyies .docx
Please use from these stratagies This homework will be to copyies .docxDIPESH30
 
PLEASE THOROUGHLY ANSWER THE FOLLOWING FIVE QUESTIONS BELOW IN.docx
PLEASE THOROUGHLY ANSWER THE FOLLOWING FIVE QUESTIONS BELOW IN.docxPLEASE THOROUGHLY ANSWER THE FOLLOWING FIVE QUESTIONS BELOW IN.docx
PLEASE THOROUGHLY ANSWER THE FOLLOWING FIVE QUESTIONS BELOW IN.docxDIPESH30
 
Please share your thoughts about how well your employer, military .docx
Please share your thoughts about how well your employer, military .docxPlease share your thoughts about how well your employer, military .docx
Please share your thoughts about how well your employer, military .docxDIPESH30
 
Please select and answer one of the following topics in a well-org.docx
Please select and answer one of the following topics in a well-org.docxPlease select and answer one of the following topics in a well-org.docx
Please select and answer one of the following topics in a well-org.docxDIPESH30
 
Please see the attachment for the actual work that is require.  This.docx
Please see the attachment for the actual work that is require.  This.docxPlease see the attachment for the actual work that is require.  This.docx
Please see the attachment for the actual work that is require.  This.docxDIPESH30
 
Please see the attachment and look over the LOOK HERE FIRST file b.docx
Please see the attachment and look over the LOOK HERE FIRST file b.docxPlease see the attachment and look over the LOOK HERE FIRST file b.docx
Please see the attachment and look over the LOOK HERE FIRST file b.docxDIPESH30
 

More from DIPESH30 (20)

please write a short essay to address the following questions. Lengt.docx
please write a short essay to address the following questions. Lengt.docxplease write a short essay to address the following questions. Lengt.docx
please write a short essay to address the following questions. Lengt.docx
 
please write a diary entry from the perspective of a French Revoluti.docx
please write a diary entry from the perspective of a French Revoluti.docxplease write a diary entry from the perspective of a French Revoluti.docx
please write a diary entry from the perspective of a French Revoluti.docx
 
Please write the definition for these words and provide .docx
Please write the definition for these words and provide .docxPlease write the definition for these words and provide .docx
Please write the definition for these words and provide .docx
 
Please view the filmThomas A. Edison Father of Invention, A .docx
Please view the filmThomas A. Edison Father of Invention, A .docxPlease view the filmThomas A. Edison Father of Invention, A .docx
Please view the filmThomas A. Edison Father of Invention, A .docx
 
Please watch the clip from the movie The Break Up.  Then reflect w.docx
Please watch the clip from the movie The Break Up.  Then reflect w.docxPlease watch the clip from the movie The Break Up.  Then reflect w.docx
Please watch the clip from the movie The Break Up.  Then reflect w.docx
 
please write a report on Social Media and ERP SystemReport should.docx
please write a report on Social Media and ERP SystemReport should.docxplease write a report on Social Media and ERP SystemReport should.docx
please write a report on Social Media and ERP SystemReport should.docx
 
Please write 200 wordsHow has the healthcare delivery system chang.docx
Please write 200 wordsHow has the healthcare delivery system chang.docxPlease write 200 wordsHow has the healthcare delivery system chang.docx
Please write 200 wordsHow has the healthcare delivery system chang.docx
 
Please view the documentary on Typhoid Mary at httpswww..docx
Please view the documentary on Typhoid Mary at httpswww..docxPlease view the documentary on Typhoid Mary at httpswww..docx
Please view the documentary on Typhoid Mary at httpswww..docx
 
Please use the two attachments posted to complete work.  Detailed in.docx
Please use the two attachments posted to complete work.  Detailed in.docxPlease use the two attachments posted to complete work.  Detailed in.docx
Please use the two attachments posted to complete work.  Detailed in.docx
 
Please use the sources in the outline (see photos)The research.docx
Please use the sources in the outline (see photos)The research.docxPlease use the sources in the outline (see photos)The research.docx
Please use the sources in the outline (see photos)The research.docx
 
Please submit a minimum of five (5) detailed and discussion-provokin.docx
Please submit a minimum of five (5) detailed and discussion-provokin.docxPlease submit a minimum of five (5) detailed and discussion-provokin.docx
Please submit a minimum of five (5) detailed and discussion-provokin.docx
 
Please think about the various learning activities you engaged in du.docx
Please think about the various learning activities you engaged in du.docxPlease think about the various learning activities you engaged in du.docx
Please think about the various learning activities you engaged in du.docx
 
Please type out the question and answer it underneath. Each question.docx
Please type out the question and answer it underneath. Each question.docxPlease type out the question and answer it underneath. Each question.docx
Please type out the question and answer it underneath. Each question.docx
 
Please use the following technique-Outline the legal issues t.docx
Please use the following technique-Outline the legal issues t.docxPlease use the following technique-Outline the legal issues t.docx
Please use the following technique-Outline the legal issues t.docx
 
Please use from these stratagies This homework will be to copyies .docx
Please use from these stratagies This homework will be to copyies .docxPlease use from these stratagies This homework will be to copyies .docx
Please use from these stratagies This homework will be to copyies .docx
 
PLEASE THOROUGHLY ANSWER THE FOLLOWING FIVE QUESTIONS BELOW IN.docx
PLEASE THOROUGHLY ANSWER THE FOLLOWING FIVE QUESTIONS BELOW IN.docxPLEASE THOROUGHLY ANSWER THE FOLLOWING FIVE QUESTIONS BELOW IN.docx
PLEASE THOROUGHLY ANSWER THE FOLLOWING FIVE QUESTIONS BELOW IN.docx
 
Please share your thoughts about how well your employer, military .docx
Please share your thoughts about how well your employer, military .docxPlease share your thoughts about how well your employer, military .docx
Please share your thoughts about how well your employer, military .docx
 
Please select and answer one of the following topics in a well-org.docx
Please select and answer one of the following topics in a well-org.docxPlease select and answer one of the following topics in a well-org.docx
Please select and answer one of the following topics in a well-org.docx
 
Please see the attachment for the actual work that is require.  This.docx
Please see the attachment for the actual work that is require.  This.docxPlease see the attachment for the actual work that is require.  This.docx
Please see the attachment for the actual work that is require.  This.docx
 
Please see the attachment and look over the LOOK HERE FIRST file b.docx
Please see the attachment and look over the LOOK HERE FIRST file b.docxPlease see the attachment and look over the LOOK HERE FIRST file b.docx
Please see the attachment and look over the LOOK HERE FIRST file b.docx
 

Recently uploaded

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 

Recently uploaded (20)

Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 

Lab08Lab08.cppLab08Lab08.cpp.docx

  • 1. Lab08/Lab08.cppLab08/Lab08.cpp//*********************** ***************************************************** ********************************** // FILE: Lab08.cpp // // DESCRIPTION: Contains the main() function. Instantiates a P ointTest object which tests the Point class. // // AUTHORS: your-name (your-email-address) // your-partner's-name (your-partners-email-address) // // COURSE: CSE100 Principles of Programming with C++, F all 2015 // // LAB INFO: Lab 8 Date/Time: your-lab-date-and- time TA: your-lab-ta //------------------------------------------------------------------------- ------------------------------------- // TESTING: // // TEST CASE 1: // ------------ // TEST CASE INPUT DATA: // Point p1 x = 11 // Point p1 y = 22 // Point p2 x = -33 // Point p2 y = -44 // // EXPECTED OUTPUT GIVEN THE INPUT: // The point p1 is (11, 22) // The point p2 is (-33, -44) // The distance between the points is 79.322 // Moving point p1...The point p1 is now at (100, 200)
  • 2. // The distance between the points is 277.894 // Moving point p2...The point p2 is now at (300, 400) // The distance between the points is 282.843 // // OBSERVED OUTPUT: // Document the output from your program when you perform th is test case // // TEST CASE RESULT: Document PASS or FAIL // // TEST CASE 2: // ------------ // TEST CASE INPUT DATA: // Point p1 x = ??? // Point p1 y = ??? // Point p2 x = ??? // Point p2 y = ??? // // EXPECTED OUTPUT GIVEN THE INPUT: // ??? Document the expected output ??? // // OBSERVED OUTPUT: // ??? Document the output from your program when you perfor m this test case ??? // // TEST CASE RESULT: ??? Document PASS or FAIL ??? //*************************************************** ***************************************************** ****** #include"PointTest.hpp" //------------------------------------------------------------------------- ------------------------------------- // FUNCTION: main() // // DESCRIPTION
  • 3. // Starting point for the program. // // PSEUDOCODE // Define a PointTest object named pointTest calling the default ctor. // Call run() on the pointTest object. // Return 0. //------------------------------------------------------------------------- ------------------------------------- ??? Lab08/Point.cppLab08/Point.cpp//************************ ***************************************************** ********************************* // FILE: Point.cpp // // DESCRIPTION: Implementation of the Point class. See Point. hpp for the class declaration. // // AUTHORS: your-name (your-email-address) // your-partner's-name (your-partners-email-address) // // COURSE: CSE100 Principles of Programming with C++, F all 2015 // // LAB INFO: Lab 8 Date/Time: your-lab-date-and- time TA: your-lab-ta //*************************************************** ***************************************************** ****** #include<cmath>// For sqrt() #include<sstream>// For stringstream class #include"Point.hpp"// For Point class declaration //-------------------------------------------------------------------------
  • 4. ------------------------------------- // CTOR: Point() // // DESCRIPTION // Default constructor. Initializes the point to be at the origin (0, 0). // // PSEUDOCODE // Call init() and pass 0 and 0 as the parameters. //------------------------------------------------------------------------- ------------------------------------- ??? //------------------------------------------------------------------------- ------------------------------------- // CTOR: Point(int, int) // // DESCRIPTION // Secondary constructor. Initializes the mX and mY data memb ers to the input params. // // PSEUDOCODE // Call init() and pass pInitX and pInitY as the params. //------------------------------------------------------------------------- ------------------------------------- ??? //------------------------------------------------------------------------- ------------------------------------- // FUNCTION: distance(Point) // // DESCRIPTION // Calculates distance from this Point to pAnotherPoint. // // PSEUDOCODE // deltaX <- GetX() - pAnotherPoint.GetX()
  • 5. // deltaY <- GetY() - pAnotherPoint.GetY() // Return the square root of deltaX * deltaX + deltaY * deltaY //------------------------------------------------------------------------- ------------------------------------- ??? //------------------------------------------------------------------------- ------------------------------------- // FUNCTION: getX() // // DESCRIPTION // Accessor function for the mX data member. // // PSEUDOCODE // Return mX. //------------------------------------------------------------------------- ------------------------------------- ??? //------------------------------------------------------------------------- ------------------------------------- // FUNCTION: getY() // // DESCRIPTION // Accessor function for the mY data member. // // PSEUDOCODE // Return mY //------------------------------------------------------------------------- ------------------------------------- ??? //------------------------------------------------------------------------- ------------------------------------- // FUNCTION: init(int, int) //
  • 6. // DESCRIPTION // Initializes mX and mY to pInitX and pInitY. // // PSEUDOCODE // Call setX() and pass pInitX as the parameter // Call setY() and pass pInitY as the parameter //------------------------------------------------------------------------- ------------------------------------- ??? //------------------------------------------------------------------------- ------------------------------------- // FUNCTION: move(int, int) // // DESCRIPTIONm // Moves the point to the new (x, y) coordinates specified by the input params. // // PSEUDOCODE // Call init() passing pNewX and pNewY as the params //------------------------------------------------------------------------- ------------------------------------- ??? //------------------------------------------------------------------------- ------------------------------------- // FUNCTION: setX(int) // // DESCRIPTION // Mutator function for the mX data member. // // PSEUDOCODE // mX <- pNewX //------------------------------------------------------------------------- ------------------------------------- ???
  • 7. //------------------------------------------------------------------------- ------------------------------------- // FUNCTION: setY(int) // // DESCRIPTION // Mutator function for the mY data member. // // PSEUDOCODE // mY <- pNewY //------------------------------------------------------------------------- ------------------------------------- ??? //------------------------------------------------------------------------- ------------------------------------- // 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 stringstr eam object, the "output" is sent to a string // object which is encapsulated within the stringstream object. F or example, // // stringstream sout; -- sout is a stringstream object which encapsulates a string. // sout << fixed << setprecision(3); --
  • 8. sout is configured so real numbers will be formatted in fixed no tation // with 3 digits after the decimal pt. // sout << "Fred"; -- The string in sout now contains "Fred". // int x = 123; // sout << ' ' << x; -- The string in sout now contains "Fred 123". // double y = 3.14159265828; // sout << endl << y; -- The string in sout now contains "Fred 123n3.142". // cout << sout.str(); -- The str() function returns the string, i.e., "Fred 123n3.142". // // Ref: http://cplusplus.com/reference/sstream/stringstream // // PSEUDOCODE // Define a stringstream object named sout calling the default ct or. // Send to sout "(" followed by the return value from getX() foll owed by ", " followed by getY() followed by ")". // Return sout.str(). //------------------------------------------------------------------------- ------------------------------------- ??? Lab08/Point.hpp //*************************************************** ***************************************************** ****** // FILE: Point.hpp //
  • 9. // DESCRIPTION: Declares a class to represent a point in the Cartesian plane. A point is represented by an // (x, y) coordinate, where both x and y are integers. // // AUTHORS: your-name (your-email-address) // your-partner's-name (your-partners-email-address) // // COURSE: CSE100 Principles of Programming with C++, Fall 2015 // // LAB INFO: Lab 8 Date/Time: your-lab-date-and-time TA: your-lab-ta //*************************************************** ***************************************************** ****** #ifndef POINT_HPP // This line, the line below it, and the #endif form what is called a preprocessor guard. #define POINT_HPP // Preprocessor guards are a hack to ensure a header file is not included multiple times. #include <string> // For string class
  • 10. using namespace std; class Point { public: Point(); // Default constructor Point(int pInitX, int pInitY); // Second constructor double distance(Point pAnotherPoint); // Calculates distance from this Point to pAnotherPoint int getX(); // Accessor function for mX data member int getY(); // Accessor function for mY data member void move(int pNewX, int pNewY); // Moves the point to a new coordinate void setX(int pNewX); // Mutator function for mX data member void setY(int pNewY); // Mutator function for mY data member string toString(); // Returns a string representation of the Point private:
  • 11. void init(int pInitX, int pInitY); // Initializes mX and mY to the params pInitX and pInitY int mX; // The x coordinate of the Point int mY; // The y coordinate of the Point }; #endif // POINT_HPP Lab08/PointTest.cppLab08/PointTest.cpp//***************** ***************************************************** **************************************** // FILE: PointTest.cpp // // DESCRIPTION: Implementation of the PointTest class. See P ointTest.hpp for more info. // // AUTHORS: your-name (your-email-address) // your-partner's-name (your-partners-email-address) // // COURSE: CSE100 Principles of Programming with C++, F all 2015 // // LAB INFO: Lab 8 Date/Time: your-lab-date-and- time TA: your-lab-ta //*************************************************** ***************************************************** ******
  • 12. #include<iomanip>// For setprecision() #include<iostream>// For cout, endl, fixed #include"PointTest.hpp"// For the PointTest class declaration #include"Point.hpp"// For the Point class declaration usingnamespace std; //------------------------------------------------------------------------- ------------------------------------- // FUNCTION: getInt() // // DESCRIPTION // Display a prompt and read a number (as an int) from the keyb oard. Return the number. //------------------------------------------------------------------------- ------------------------------------- int getInt(string pPrompt) { cout << pPrompt; int n; cin >> n; return n; } //------------------------------------------------------------------------- ------------------------------------- // CTOR: PointTest() // // DESCRIPTION // Default constructor. Does nothing. // // REMARKS // Every class must have at least one ctor, because when an obje ct is instantiated, a ctor must be called. If // there are no data members to initialize, then we just provide a default ctor that does nothing.
  • 13. //------------------------------------------------------------------------- ------------------------------------- PointTest::PointTest() { } //------------------------------------------------------------------------- ------------------------------------- // 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 notatio n 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() foll owed by endl. // Send to cout "The point p2 is " followed by p2.toString() foll owed by endl. // Send to cout "The distance between the points is " followed b y 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.toStrin g() followed by endl. // Send to cout "The distance between the points is " followed b
  • 14. y 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.toStrin g() followed by endl. // Send to cout "The distance between the points is " followed b y p1.distance(p2) followed by endl. //------------------------------------------------------------------------- ------------------------------------- ??? Lab08/PointTest.hpp //*************************************************** ***************************************************** ****** // FILE: PointTest.hpp // // DESCRIPTION: Declares a class that will be used to test the Point class. // // AUTHORS: your-name (your-email-address) // your-partner's-name (your-partners-email-address) // // COURSE: CSE100 Principles of Programming with C++, Fall 2015 //
  • 15. // LAB INFO: Lab 8 Date/Time: your-lab-date-and-time TA: your-lab-ta //*************************************************** ***************************************************** ****** #ifndef POINTTEST_HPP #define POINTTEST_HPP // Class declaration for a class named PointTest. The class only has one constructor, the default constructor. // The run() function is called to perform the testing of the Point class. // See the PointTest UML class diagram in the lab project document. ??? #endif