Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Course.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <iomanip>
- #include <math.h>
- #include <string>
- using namespace std;
- const double pi = 3.14159265359;
- class Point
- {
- private:
- double x;
- double y;
- public:
- Point();
- Point(double cx, double cy);
- Point(double cx);
- Point(Point &cord);
- Point& operator=(Point &cord);
- double get_X();
- double get_Y();
- bool operator <=(Point cord);
- void set_X(double cx);
- void set_Y(double cy);
- void set_cord(double cx, double cy);
- void inputP();
- void outputP();
- friend ostream& operator<<(ostream& output, Point cord);
- };
- Point::Point() {
- this->x = 0;
- this->y = 0;
- }
- Point::Point(double cx, double cy) {
- this->x = cx;
- this->y = cy;
- }
- Point::Point(double cx) {
- x = cx;
- y = 0;
- }
- Point::Point(Point &cord) {
- x = cord.x;
- y = cord.y;
- }
- Point& Point::operator=(Point &cord) {
- x = cord.x;
- y = cord.y;
- return *this;
- }
- double Point::get_X() {
- return x;
- }
- double Point::get_Y() {
- return y;
- }
- bool Point::operator <=(Point cord) {
- if (this->y != cord.y) {
- cout << "error !!!";
- return false;
- }
- else
- if (this->x < cord.y) return true;
- else return false;
- }
- void Point::set_X(double cx) {
- this->x = cx;
- }
- void Point::set_Y(double cy) {
- this->y = cy;
- }
- void Point::set_cord(double cx, double cy) {
- this->x = cx;
- this->y = cy;
- }
- void Point::inputP() {
- cout << "X= ";
- cin >> x;
- cout << "Y= ";
- cin >> y;
- }
- void Point::outputP() {
- cout << "[" << this->x << ", " << this->y << "]";
- }
- ostream& operator<<(ostream& output, Point cord) {
- cout << cord.x << " " << cord.y;
- return output;
- }
- class Ellipse : public Point
- {
- private:
- double small;
- double big;
- public:
- Ellipse();
- Ellipse(double csmall, double cbig, double cx, double cy);
- Ellipse(double csmall, double cbig, Point cord);
- Ellipse(Ellipse &el);
- Ellipse& operator=(Ellipse &el);
- double get_small();
- double get_big();
- Point get_center();
- bool operator ==(Ellipse el);
- void set_Ellipse(double csmall, double cbig, double cx, double cy);
- double areaEl();
- double perEl();
- bool isInside();
- void inputEl();
- void outputEl();
- };
- Ellipse::Ellipse() : Point() {
- double small = 0;
- double big = 0;
- }
- Ellipse::Ellipse(double csmall, double cbig, double cx, double cy)
- : Point(cx, cy) {
- csmall = small;
- cbig = big;
- }
- Ellipse::Ellipse(double csmall, double cbsig, Point cord) : Point(cord) {
- small = csmall;
- big = cbig;
- }
- Ellipse::Ellipse(Ellipse &el) : Point(el) {
- small = el.small;
- big = el.big;
- }
- Ellipse& Ellipse::operator=(Ellipse &el) {
- if (this != &el)
- {
- Point::operator=(el);
- small = el.small;
- big = el.big;
- return*this;
- }
- }
- Point Ellipse::get_center() {
- Point center;
- center.set_X(this->get_X());
- center.set_Y(this->get_Y());
- return center;
- }
- void Ellipse::outputEl() {
- cout << small << "\t" << big << "Center:";
- outputP();
- }
- double Ellipse::get_big() {
- return big;
- }
- double Ellipse::get_small() {
- return small;
- }
- bool Ellipse::operator ==(Ellipse el) {
- return big == el.big;
- }
- void Ellipse::set_Ellipse(double csmall, double cbig, double cx, double cy) {
- small = csmall;
- big = cbig;
- this->set_X(cx);
- this->set_Y(cy);
- }
- void Ellipse::inputEl() {
- cout << "small - "; cin >> small;
- cout << "big - "; cin >> big;
- this->inputP();
- }
- double Ellipse::areaEl() {
- return small * big * pi;
- }
- double Ellipse::perEl() {
- return pi*(1.5 * (small + big) - sqrt(small * big));
- }
- bool Ellipse::isInside() {
- return 1;
- }
- int main()
- {
- Point P;
- Ellipse E;
- P.set_X(3.4);
- P.set_Y(12.4);
- P.outputP();
- cout << endl;
- P.inputP();
- E.set_Ellipse(1, 2, 3, 4);
- cout<< E.areaEl();
- cout << endl;
- E.outputEl();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement