Funktionen: Circle circle.cc

#include "circle.h"

int Circle::number=0;

Circle::Circle(const int x, const int y, 
               const int radius) : Point(x, y)
{ 
  number++;
  Circle::radius = radius;  
}

Circle::Circle(const Point& p, 
               const int radius) : Point(p)
{ 
  number++;
  Circle::radius = radius; 
}

Circle::Circle(const Circle& c) : Point((Point&)c)
{
  number++;
  radius=c.radius;
}


Circle::~Circle()
{
  number--;
}

float Circle::area()
{ return (PI*radius*radius); }

float Circle::perimeter()
{ return (PI*radius*2); }

int Circle::intersects(Circle& c)
{
  return distance(c) < (radius+c.radius);
}

int Circle::getRadius()
{ return radius; }

ostream& operator<<(ostream& s, Circle& c)
{
  return s << (Point&) c << " with radius " << c.radius;
}

previous up next


© 1997 Gottfried Rudorfer, C++-AG, Lehrveranstaltungen, Abteilung für Angewandte Informatik, Wirtschaftsuniversität Wien, 12/16/1998