I need help with these two programming problems given the starter code below. La
ID: 3732818 • Letter: I
Question
I need help with these two programming problems given the starter code below. Language is C++, thanks!
Part A Starter
#include <iostream>
}
Part B starter
return 0;
}
Part A Starter
#include <iostream>
using namespace std; // We have setup class framework for you. // Please add cin/cout overload first and at the same time add the coordinates // // See github example as specified in the assignment handout for exaamples // class Point { public: friend istream& operator>>(istream &input, Point &p ) { // Finish me second by adding proper input >> statement return input; } friend ostream& operator<<(ostream &output, const Point &p ) { // Finish me thrid by adding proper output << statement return output; } // Please add constructors and other functions here. private: // Add me first }; int main() { Point P1; cout << "Enter P1: "; cin >> P1; cout << "P1: "; cout << P1; cout << endl; return 0;}
Part B starter
#include <iostream> using namespace std; // We have setup class framework for you. Please copy the point // class you created to this file. class Line { public: private: }; int main() { Line L1; // cout << "Enter L1: "; // cin >> L1; // cout << "L1: "; // cout << L1; // cout << endl;return 0;
}
Part A: Create Point Class (point class.cpp) - Milestone part A: Problem Statement: Create a an object to implement a "point" class which allows a programmer to store an x, y coordinate pair. It should have at least two constructors, a set function, gt functions for xe and y, and overloaded I/O (cin/cout) functions. Part B: (line_class.cpp) - Milestone Part B Problem Statement: Create an object to implement a "line" class which allows the programmer to store a line. This class must use the "point" class developed in Part A. The object should have two constructors, appropriate set/get functions, and overloaded I/O (cin/cout) functions. It should include functions the return the proper value for the following: Determine the slope of a line Determine the length of a line Determine the y-intercept of a line Determine if the line is horizontal Determine if the line is vertical Determine if a line is parallel to another line Determine if a line intersects another line » .Explanation / Answer
Below is the solution for problem A:
#include <iostream>
using namespace std;
// We have setup class framework for you.
// Please add cin/cout overload first and at the same time add the coordinates
//
// See github example as specified in the assignment handout for exaamples
//
class Point {
public:
Point() {
x = 0;
y = 0;
}
Point(int a,int b) {
x = a;
y = b;
}
friend istream& operator>>(istream &input, Point &p ) {
// Finish me second by adding proper input >> statement
input >> p.x >> p.y;
return input;
}
friend ostream& operator<<(ostream &output, const Point &p ) {
// Finish me thrid by adding proper output << statement
output << "X coordinate is: " << p.x << " and Y coordinate is: " << p.y;
return output;
}
// Please add constructors and other functions here.
private:
// Add me first
int x;
int y;
};
int main() {
Point P1;
cout << "Enter P1: ";
cin >> P1;
cout << "P1: ";
cout << P1;
cout << endl;
return 0;
}
Please post a different question for B as that will take a lot of time and can not be done in same time