Straight Line and Classes ( 50 Points ) image4-1.png Create a class called Line as specified in the UML diagram above. The definition of the class goes inside the file Line.h, whereas the...

Straight Line and Classes ( 50 Points ) image4-1.png Create a class called Line as specified in the UML diagram above. The definition of the class goes inside the file Line.h, whereas the implementation will be detailed in Lineimpl.cpp. You should implement two different constructors of the class, as in the diagram. The default constructor sets the slope as 2 and intercept as 5. The parameterized constructor initializes the slope and parameter accordingly. You should implement the function printLine() that prints the line in the form of y = 4x + 11, if a line object has slope 4 and intercept 11. You should implement the getter and setter function for the slope and intercept appropriately. Implement the function checkParallel(Line&) that takes a second line as an argument and check if two lines are parallel. ( Two lines are parallel if they have equal slope). Implement the function checkPerpendicular(Line&) that takes a second line as an argument and check if two lines are perpendicular. ( Two lines are perpendicular if the product of the slopes is -1). Create a driver.cpp file that does the following operation : i) Create a Line object line1 with slope 6 and intercept 8. ( Create the object using the default constructor and use the setSlope and setIntercept function) , and print the line using printLine function. ii) Create a Line object line2 with slope -6 and intercept 10. ( Create the object using a parameterized constructor), and print the line using printLine iii) Create a Line object line3 with slope 5 and intercept 5.( Create the object using a parameterized constructor), and print the line using printLine function. iv) Create a Line object line4 with slope 5 and intercept 17.( Create the object using a parameterized constructor), and print the line using printLine v) Check if line1 and line3 are parallel to each other. vi) Check if line1 and line2 are perpendicular to each other. vii) Check if line3 and line4 are parallel to each other. Files to upload: You need to upload Line.h , Lineimpl.cpp and driver.cpp file 2. Geometry and Inheritance (100 Points) The inheritance hierarchy for the classes you will design look like : image5.png Figure: Inheritance Hierarchy for the classes a) image2.png Create a header file called geom_point.h to store the definition of the class and the functions as specified in the UML diagram, implement the functions, as reflected by the name of getter and setter functions in an implementation file called geom_point_impl.cpp. You should also implement the constructor that initializes both of the private members with the parameters and the print function that prints the Point in the form of cartesian coordinates Example: if the Xcoord is 5.3, and Ycoord is 3.2 your function should print (5.3,3.2). b) image1.png Create a header file called geom_circle.h to store the definition of the class and the functions as specified in the UML diagram. The class geom_circle inherits publicly from geom_point. Implement the functions, as reflected by the name of getter and setter functions in an implementation file called geom_circle_impl.cpp. You should also implement the constructor that initializes the radius of the circle and tacks on the parent constructor with the values for Xcoord, and Ycoord. Also, implement the function getCircumference() and getArea() that calculates the circumference and area of the circle. You need to overload the function printgeom() in the geom_circle class that calls the parent function of printgeom() printing the center of the circle. The overloaded function also prints the radius, area, and circumference of the circle. c) CylinderClass Create a header file called geom_cylinder.h to store the definition of the class and the functions as specified in the UML diagram. The class geom_cylinder inherits publicly from geom_circle. Implement the functions of the class in an implementation file called geom_cylinder_impl.cpp. Create the getter and setter function for manipulating height. You should overload the function printgeom() and call the parent class(Circle’s) function to print the details of the base circle. The function should additionally print the surface area and the volume of the cylinder. You should also implement the constructor that initializes the height of the cylinder, and tacks on the radius of the circle, Xcoord, Ycoord to its parent constructor (Reason behind the constructor having 4 arguments). You also need to implement a function called combineCylinders that takes another cylinder object as an argument and creates a new cylinder which has the Xcoord and Ycoord as the midpoint of the two cylinder’s points. The radius of the new cylinder is the sum of the radius of cylinder objects whereas the height is the sum of the heights of the cylinder objects. Your function should return this newly created combined cylinder. d) Finally, write a driver.cpp file that tests the functionality of your classes. Create 2 different cylinders as detailed below cyl1 and cyl2, and print the details of the cylinder using the overloaded printgeom() function. Cylinder Object XCoord YCoord Radius Height cyl1 10.3 11.4 5.6 11.2 cyl2 3.3 4.4 10.5 6.3 combined 6.8 7.9 16.1 17.5 Create the combined cylinder object by calling the function combineCylinders on the object cyl1 passing cyl2 as the parameter. Your function should return you a new cylinder which has the properties initialized as discussed before in the details of combineCylinders function. Print the details of the combined cylinder using the printgeom() function. Note: You can only manually assign the cyl1 and cyl2 objects using constructor and predefined values for XCoord, YCoord, Radius, and Height. The combined cylinder should be returned from the function and it should be initialized using the rule we discussed above. Files to upload: You need to implement geom_point.h, geom_point_impl.cpp, geom_circle.h, geom_circle_impl.cpp, geom_cylinder.h, geom_cylinder_impl.cpp and driver.cpp
Nov 23, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here