Hi,
Hi guys I am new to C++ but never wrote such a program actually i needed your help on this. It seems a difficult one but i hope if u guys could help me.
Thanks alot guys
The point P1 has coordinates {X1,Y1}.
The point P2 has coordinates {X2,Y2}.
The length of the line joining P1 and P2 is given by the equation:
{ (X2 - X1)2 + (Y2 - Y1)2 }1/2
Requirements:
Develop a class specification for the class Point (the data members and the prototypes for the member functions) in the file point.h.
Develop the implementation of the member functions in the file point.cc and test them with a suitable test program.
For example:
//pointTest.cc
Code:
int main()
{
Point P1;
P1.create(24,16); // create a point with coordinates {24,16}
P1.display(); // display the {X,Y} coordinates of P1
.....
}
Develop a class specification for the class Line (the data members and the prototypes for the member functions) in the file line.h.
Develop the implementation of the member functions in the file line.cc and test them with a suitable test program.
For example:
//lineTest.cc
Code:
int main()
{
Point P1;
P1.create(24,16); // create a point with coordinates {24,16}
Point P2;
P2.create(33,42); // create a point with coordinates {33,42}
Line L1;
L1.create(P1,P2); // create a line using points P1 and P2
cout << L1.length() << endl; // display the length of line L1
Line L2;
L2.create(12,30,28,16); // create a line using coordinates {12,30}, {28,16}
L2.display(); // display the coordinates of both points
.....
}
Application:
I need to determine the length of the boundary of an irregular polygon.
The polygon may have up to 9 sides.
The user should be prompted to enter the number of sides and the coordinates of each vertex point.
The program should then calculate and display the total length of the boundary.
I will need to write a main function to implement this using your Point and Line classes and test the program thoroughly.
Junaid