(Solved) : Shape Virtual Print 0 Point Line Triangle Circle Double Xcoor Point P1 Point P2 Point P Do Q42678196 . . .

Please use C++. Will thumbs up. Thanks.

Shape virtual print (=0 Point Line Triangle Circle double x_coor Point p1 Point p2 Point p double radius double y coor Pointi) Implement the above classes with the needed set/get functions. Then create the following objects, Point pl (4.1, 3.2) Poin

Shape virtual print (=0 Point Line Triangle Circle double x_coor Point p1 Point p2 Point p double radius double y coor Point p1 Point p2 Point p3 Assume that Shape class is an abstract class and Point, Line, Triangle and Circle are concrete classes derived from the Shape class. Assume that the classes have default constructors as well as regular constructor functions as follows, Point (double, double), Line ( Point, Point), Triangle (Point, Point, Point), Circle (Point, double). Then perform the following tasks, i) Implement the above classes with the needed set/get functions. Then create the following objects, Point pl (4.1, 3.2) Point p2 (9.3, 4.7) Line line (p1, p2) Point p3 (5.8, 7.3) Triangle triangle (p1, p2, p3) Point p( 2,5, 8.4) Circle (p, 2.9) ii) Create a sequential access file and store these objects in that file (if creation of the file isnot successful, throw an exception and terminate the execution). An object will be stored in the file by writing the object’s class name as a string (note that class name isnot a data member of an object) and then the values of its data members, with single space between the fields. The above objects will be stored as follows, Object Field IV Field V Field VI Field VII | p2 line 9.3 4.7 Field I Point Point Line Point Triangle Point Circle Field II 4.3 9.3 4.3 5.8 4.3 2.5 2.5 Field III 3.2 4.7 | 3.2 7.3 3.2 8.4 8.4 p3 triangle 9.3 4.7 5.8 7.3 Lp circle 2.9 iii) Create a pointer array of the Shape class and initialize it to nullpointer values. iv) Read the stored objects from the file. After determining the class of an object from Field I, create that object using dynamic memory allocation and store object’s address in the Shape class pointer array. Then, read the values of the remaining fields and store them in the object’s data members. v) Display the values of the data members of these objects through the print () functions. Note: The solution should be general not only applicable to the given example. Show transcribed image text Shape virtual print (=0 Point Line Triangle Circle double x_coor Point p1 Point p2 Point p double radius double y coor Point p1 Point p2 Point p3 Assume that Shape class is an abstract class and Point, Line, Triangle and Circle are concrete classes derived from the Shape class. Assume that the classes have default constructors as well as regular constructor functions as follows, Point (double, double), Line ( Point, Point), Triangle (Point, Point, Point), Circle (Point, double). Then perform the following tasks,
i) Implement the above classes with the needed set/get functions. Then create the following objects, Point pl (4.1, 3.2) Point p2 (9.3, 4.7) Line line (p1, p2) Point p3 (5.8, 7.3) Triangle triangle (p1, p2, p3) Point p( 2,5, 8.4) Circle (p, 2.9) ii) Create a sequential access file and store these objects in that file (if creation of the file isnot successful, throw an exception and terminate the execution). An object will be stored in the file by writing the object’s class name as a string (note that class name isnot a data member of an object) and then the values of its data members, with single space between the fields. The above objects will be stored as follows, Object Field IV Field V Field VI Field VII | p2 line 9.3 4.7 Field I Point Point Line Point Triangle Point Circle Field II 4.3 9.3 4.3 5.8 4.3 2.5 2.5 Field III 3.2 4.7 | 3.2 7.3 3.2 8.4 8.4 p3 triangle 9.3 4.7 5.8 7.3 Lp circle 2.9 iii) Create a pointer array of the Shape class and initialize it to nullpointer values. iv) Read the stored objects from the file. After determining the class of an object from Field I, create that object using dynamic memory allocation and store object’s address in the Shape class pointer array. Then, read the values of the remaining fields and store them in the object’s data members. v) Display the values of the data members of these objects through the print () functions. Note: The solution should be general not only applicable to the given example.

Expert Answer


Answer to Shape virtual print (=0 Point Line Triangle Circle double x_coor Point p1 Point p2 Point p double radius double y coor P…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us