. Circle and Rectangle

Source: Internet
Author: User
Tags gety

#include <iostream>
#include <cmath>
using namespace Std;

Class point{

Private

Double x, y;

Public

Point ();

Point (double xv,double yv);

Point (point& PT);

Double Getx ();

Double Gety ();

};

Point::P oint () {
x=0;y=0;
}

Point::P oint (double xv,double yv) {
X=XV;Y=YV;
}

Point::P oint (point& PT) {
This->x = Pt.x;
This->y = Pt.y;
}

Double Point::getx () {
return x;
}
Double Point::gety () {
return y;
}


Class Circle:public point{
Public
Circle (double x,double y,double R);
Circle ();
Circle (Circle &);
int position (point &pr) {
Double A = POW (Pr.getx ()-This->getx (), 2) + POW (pr.gety ()-This->gety (), 2);
if (a==r*r) return 0;
if (a>r*r) return 1;
if (a<r*r) return-1;
}
Private
Double R;
};

Circle::circle (double x,double y,double R): Point (x, y) {
this->r=r;
}

Circle::circle (): Point () {
r=0;
}

Circle::circle (Circle &t): Point (T.getx (), t.gety ()) {
R = T.R;
}

Class Rectangle:public point{
Public

Rectangle (double x,double y,double len,double wid): Point (x, y) {
this->len=len;
this->wid=wid;
}
Rectangle ();
Rectangle (Rectangle &);
int position (point &pr) {
Double A = Pr.getx ()-This->getx ();
Double b = pr.gety ()-this->gety ();
cout<<a<< "KKKK" <<b<<endl;
if ((a==0&&b<=wid&&b>0) | | | (a>0&&a<=len&&b==0) | | (a==len&&b<=wid&&b>0) | | (A>0&&a<=len&&b==wid)) return 0;
if (a<len&&a>0&&b<wid&&b>0) return-1;
else if (a>len| | b>wid| | a<0| | B&LT;0) return 1; Wai
else return 0; Zai
}
Private
Double Len;
Double wid;
};

Rectangle::rectangle (): Point () {
Len=1;
wid=1;
}
Rectangle::rectangle (Rectangle &t): Point (T.getx (), t.gety ()) {
len = T.len;
WID = T.wid;
}

. Circle and Rectangle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.