home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
IOC
/
GRAPH
/
LINE.H
< prev
Wrap
Text File
|
1995-03-15
|
2KB
|
73 lines
/*************************************************************************
IBM C/C++ Tools Version 3.00 - Collection Class Library
(C) Copyright IBM Corporation 1992 ,1995, Licensed Program-Property of
IBM. All Rights Reserved. US Government Users Restricted Rights - Use,
duplication or disclosure restricted by GSA ADP Schedule Contract with
IBM Corp.
*************************************************************************/
#if defined (_SUN)
#include <istring.h>
#else
#include <istring.hpp>
#endif
#include <math.h>
class Line : public Graphics
{
public:
double ivXStart;
double ivYStart;
double ivXEnd;
double ivYEnd;
Line(int graphicsKey, IString id, double xstart, double ystart,
double xend, double yend)
: Graphics(graphicsKey, id),
ivXStart(xstart),
ivYStart(ystart),
ivXEnd(xend),
ivYEnd(yend)
{ }
IBoolean operator== (Line const& line) const
{
return (this->ivXStart == line.ivXStart &&
this->ivYStart == line.ivYStart &&
this->ivXEnd == line.ivXEnd &&
this->ivYEnd == line.ivYEnd);
}
void draw() const
{
cout << "drawing "
<< Graphics::id()
<< endl
<< "with starting point: "
<< "(" << this->ivXStart
<< "|" << this->ivYStart << ")"
<< " and with ending point: "
<< "(" << this->ivXEnd
<< "|" << this->ivYEnd << ")"
<< endl;
}
void lengthOfLine() const
{
cout << "The length of line "
<< Graphics::id()
<< " is: "
<< sqrt(pow(((this->ivXEnd) - (this->ivXStart)),2)
+ pow(((this->ivYEnd) - (this->ivYStart)),2))
<< endl;
}
};