Question: Design and implement a C++ program based on the concept of composition. The program represents lines for computer graphic and each line consist of

Design and implement a C++ program based on the concept of composition.  


Design and implement a C++ program based on the concept of composition. The program represents lines for computer graphic and each line consist of 2 points. Declare the class Point and Line to model the line and points in computer graphic in 2 dimensional space. Line object has an array of Point object as members. In term of classes relationship, Line class has Point class. Use the following driver function. You must not change the driver function and when executed it should produce the output listed below. Driver function int main() { Line oLine1("line1", 21, 3, 3,4); // connect p1(21,3) with p2(3,4) oLine1.showPointsInLine(); cout < < endl; Line oLine2("line2", 87, 13, 11, 40); // connect p3 (87,13) with p4 (11,40) oLine2.showPointsInLine(); cout < < endl < < endl;; Expected output The 2 points for linel are The 2 points for line2 are (21, 3) (3, 4) (87, 13) (11, 40)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!