Total members 11895 |It is currently Mon Dec 30, 2024 5:37 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Circle class in C++
cpp code
// ircle.cpp: implementation of the Circle class.
//
#include<iostream>
using namespace std;
//////////////////////////////////////////////////////////////////////
#include<math.h>
#include "ircle.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Circle::Circle()
{

}

Circle::~Circle()
{

}

double Circle ::Getdiameter()
{
return Radius*2;


}
double Circle ::Getarea()

{
double area;
area=(3,14*Radius*Radius);
return area;


}
bool Circle ::Included(Point P1,Point P2)
{

Length=sqrt((P1.SetX()-P2.SetX())^2+(P1.SetY()-P2.SetY())^2);
if(Length>Radius)
return true;
return false;

}


////////////////////////////////////////////////////////////////////////////////////////////////
int Circle ::Cir_Cir(Point P1, Point P2,int r)
{
if((Radius==r&&P1.SetX()==P2.SetX())&&(P1.SetY()==P2.SetY()))
{
pass=Equal;
return pass;
}
else if((Radius>=r&&Length<=Radius))
{
pass=included;
return pass;
}
else if (Radius>=r&&Length>Radius||Radius<=r&&Length>r)
{
pass=Disjoint;
return pass;
}
else if (Radius<=r&&Length<=r)
{
pass=Super;
return pass;
}
else
pass=Intercepted;


return pass;






}


void Circle ::GetDstance(Point P1,Point P2)
{


Length=sqrt((P2.SetX()-P1.SetX())^2+(P2.SetY()-P1.SetY())^2);

}

void Circle ::GetRadius(int r)
{
Radius=r;

}
int Circle::SetRadius()
{
return Radius;
}

int Circle ::Test(Point P)
{

return 0;

}


.h file
cpp code
// ircle.h: interface for the Circle class.
//
//////////////////////////////////////////////////////////////////////
#include "Point.h"
#if !defined(AFX_IRCLE_H__12EBF9DB_8FA6_4245_AA48_97AEA3A3605E__INCLUDED_)
#define AFX_IRCLE_H__12EBF9DB_8FA6_4245_AA48_97AEA3A3605E__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

enum Pass{Disjoint,included,Super,Intercepted,Equal};
class Circle:public Point
{
public:
Circle();
virtual ~Circle();
//////////////////////////////////////////////////////////////////////////////////////////////

void GetRadius(int r);
int Cir_Cir(Point P1,Point P2,int r);

int SetRadius();
double Getdiameter();
double Getarea();
bool Included(Point P1,Point P2);
void GetDstance(Point P1,Point P2);
int Test(Point P);
protected :
int Radius;
double Length;


Pass pass;


};

#endif // !defined(AFX_IRCLE_H__12EBF9DB_8FA6_4245_AA48_97AEA3A3605E__INCLUDED_)

Related Point.h:
c-examples/point-class-in-c-t10810.html



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Circle class in C++
 Drawing circle using circle equation directly , on mouse     -  
 Define class helper class to check the method existance     -  
 java abstract class,concrete class and interface     -  
 php drawing a circle     -  
 relationship between the Canvas class and the Graphics class     -  
 compute area of the circle.     -  
 php drawing a circle with imagearc()     -  
 Circle drawing using Bresenham     -  
 Calculate the area of a circle of given radius     -  
 rotate sphere in a circle with light     -  



Topic Tags

C++ OOP
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com