Question
#include using namespace std; class Point { private: double x, y; public: Point() { this->x = 0; this->y = 0; } Point(int x, int y)
#include
using namespace std;
class Point {
private: double x, y;
public: Point() { this->x = 0; this->y = 0; } Point(int x, int y) { this->x = x; this->y = y; }
void set_point(double x0, double y0){ this->x = x0; this->y = y0; }
void set_x(double x0) { this->x = x0; }
void set_y(double y0) { this->y = y0; }
double get_x() { return this->x; }
double get_y() { return this->y; }
friend ostream &operator<<( ostream &output, const Point &P ) { output << "x : " << P.x << " y : " << P.y << endl; return output; }
friend istream &operator>>( istream &input, Point &P ) { cout << "Enter x: "; input >> P.x; cout << "Enter y: "; input >> P.y; return input; } };
int main() {
// initializes Point a to coorindates x: 5.2 and y: -4.8 Point a(5.2, -4.8); // initializes Point b to coorindates x: 0 and y: 0 Point b; cout << "Point a: " << a.get_x() << ", " << a.get_y() << endl; cout << "Point b: " << b.get_x() << ", " << b.get_y() << endl;
// set points b to point x: 3 and y: 5 // b.set_x(3); // b.set_y(5);
// b.set_point(3, 5); cout << "Point b: " << b.get_x() << ", " << b.get_y() << endl; Point x1; cout << "Input a point"<
Point class given above ^ (Updated)
Problem 3: Coding done in C++
Create an object to implement a triangle class which allows the programming to store a triangle object. The object should either the line or point class developed previously. The object should have at least two constructors, appropriate set/get functions, and overloaded I/O functions. It should include functions the return the proper value for the following:
-Determines if the your object is a triangle
-Calculates the area of a triangle
-Determines the perimeter of the triangle
-Is your triangle a right triangle
-Is your triangle is a an equilateral triangle
Any Help Appreciated.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started