THIS IS THE HEADER FILE WITH THE RMES THAT WAS PROVIDED TO M
THIS IS THE HEADER FILE WITH THE RMES THAT WAS PROVIDED TO ME:
#ifndef POINT_H
 #define POINT_H
#include <iostream>
 using namespace std;
 class Point
 {
 public:
 /**
 * Requires: Nothing.
 * Modifies: x, y.
 * Effects: Default contructor. Sets point to origin (0,0).
 */
    Point();
   
 /**
 * Requires: Nothing.
 * Modifies: x, y.
 * Effects: Constructs a point and sets x and y coordinates.
 * Note: you will want to implement the private
 * member function checkRange() before
 * implementing this one
 */
    Point(int xVal, int yVal);
   
 /**
 * Requires: Nothing.
 * Modifies: x.
 * Effects: Sets x coordinate.
 */
    void setX(int xVal);
/**
 * Requires: Nothing.
 * Modifies: Nothing.
 * Effects: Returns x coordinate.
 */
    int getX();
   
 /**
 * Requires: Nothing.
 * Modifies: y.
 * Effects: Sets y coordinate.
 */
    void setY(int yVal);
   
 /**
 * Requires: Nothing.
 * Modifies: Nothing.
 * Effects: Returns y coordinate.
 */
    int getY();
 
 /**
 * Requires: ins is in good state.
 * Modifies: ins, x, y.
 * Effects: Reads point in form (x,y).
 */
 void read(istream& ins);
   
 /**
 * Requires: outs is in good state.
 * Modifies: outs.
 * Effects: Writes point in form (x,y).
 */
 void write(ostream& outs);
private:
 int x;
 int y;
   
 /**
 * Requires: nothing
 * Modifies: nothing
 * Effects:
 * Effects: Returns val if val is in range [0,DIMENSION),
 * otherwise returns the closest of 0 and DIMENSION - 1.
 */
 int checkRange(int val);
   
/**
 * Overloading >> and << for reading a Point from streams.
 * Example on how to use these:
 * Point pt;
 * cout << \"Please enter a point using format (x,y) : \";
 * cin >> pt;
 * cout << \"\ the point you just entered is: \";
 * cout << pt << endl;
 */
 istream& operator >> (istream& ins, Point& pt);   
 ostream& operator << (ostream& outs, Point pt);
#endif
MY ATTEMPT AT COMPLETEING THE CPP FILE BUT IT WONT COMPILE SO I DONT EVEN KNOW IF THERE ARE LOGIC ERRORS AFTER THAT. Please help me fix this program (both why it won\'t compile and make it follow the RMEs correctly)
#include \"Point.h\"
// for the declaration of DIMENSION
 #include \"utility.h\"
// TODO: implement two constructors, setX, getX, setY, getY, read, write, checkRange.
 Point::Point() { // Default constructor
    x = 0;
    y = 0;
   
 }
void Point::setX(int xVal) {
    x = xVal;
 }
int Point::getX() {
    return x;
 }
void Point::setY(int yVal) {
    y = yVal;
 }
int Point::getY() {
    return y;
 }
void Point::read(istream& ins) {
    char junk;
    char junk2;
    char junk3;
ins >> junk >> x >> junk2 >> y >> junk3;
   
 }
void Point::write(ostream& outs) {
   
        outs << \"(\" << x << \",\" << y << \")\";
   
 }
int Point::checkRange(int val){
 if ((val >= 0) && (val < DIMENSION)) {
    return val;
 }
 else {
    if ((val - (DIMENSION - 1)) > val) {
        return 0;
    }
    else {
        return (DIMENSION - 1)
    }
 }
 }
Point::Point(int xVal, int yVal) { // Second constructor
    x = xVal;
    y = yVal;
 }
// Your code goes above this line.
 // Don\'t change the implementations below!
istream& operator >> (istream& ins, Point& pt)
 {
 pt.read(ins);
 return ins;
 }
ostream& operator<< (ostream& outs, Point pt)
 {
 pt.write(outs);
 return outs;
 }
Solution
Use the below implementation in Point.cpp file:
Use the below implementation in Point.cpp file:
#include \"point.h\"
// for the declaration of DIMENSION
 #include \"utility.h\"
using namespace std;
//Default constructor that initializes point to (0,0)
 Point::Point(){
 x=0;
 y=0;
 }
//Overloaded constructor for setting x and y
 Point::Point(int xVal,int yVal){
 x=xVal;
 y=yVal;
 }
//set function for X
 void Point::setX(int xVal){
 x=xVal;
 }
//get function for X
 int Point::getX() const{
 return x;
 }
//set function for Y
 void Point::setY(int yVal){
 y=yVal;
 }
//get function for Y
 int Point::getY() const{
 return y;
 }
// read function for extracting a point
 void Point::read(istream& ins) {
 char junk;
 char junk2;
 char junk3;
 ins >> junk >> x >> junk2 >> y >> junk3;
   
 }
// write function for sending a point
 void Point::write(ostream& outs) {
   
 outs << \"(\" << x << \",\" << y << \")\";
   
 }
int Point::checkRange(int val){
 if ((val >= 0) && (val < DIMENSION)) {
 return val;
 }
 else {
 if ((val - (DIMENSION - 1)) > val) {
 return 0;
 }
 else {
 return (DIMENSION - 1)
 }
 }
 }
//Overloaded << operator for sending a Point to an output stream
 ostream& operator<<(ostream& outs,const Point &pt){
 //print out the Point as \"(x,y)\"
 pt.write(outs);
 return outs;
 }
//Overloaded >> operator for extracting a Point from a stream
 istream& operator>>(istream& ins, Point &pt){
 pt.read(ins);
 return ins;
 }





