Torres_Michael_Lab3 copy.cpp - Michael Torres/Lab 3 Using...

This preview shows page 1 - 2 out of 3 pages.

// Michael Torres //Lab 3: Using Member and Non-Member Functions #include <iostream> #include <cmath> using namespace std; // Defining the Class that I will be using class MyPoint{ private: //These are the private variables that will be used for assigning coords to objects int xCoord; int yCoord; public: MyPoint(); //Default Constructor MyPoint(int x, int y); //Constructor with parameters //Could write MyPoint(int, int) but not self documented MyPoint(int x); //Constructor with only 1 parameter int getX() const; // Used to return the x value void setX(int); //Used to assign the x value int getY() const; //Used to return the y value void setY(int); // Used to assign the y value void print() const; //Used to print the coordinates bool areInSameQuadrant(MyPoint p1); //Checks if in the same Quadrand void SwapCoord(); //Swaps the Coordinates bool EqualPoints(MyPoint p1); //Checks to see if points are equal }; // Default Constructor MyPoint::MyPoint(){ xCoord=0; yCoord=0; } //Constructor with parameters MyPoint::MyPoint(int x, int y){ xCoord=x; yCoord=y; } // Constructor with one parameter

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture