Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ language 5. Any class you create must not have any public data members. Create the following classes: (a) [1 point] A point class to
C++ language
5. Any class you create must not have any public data members. Create the following classes: (a) [1 point] A point class to represent x and y coordinates of a point on the coordinate system. You can assume that x and y can only have integer values. Provide a get and a set function for each data member. Create a default constructor to initialize x and y to 0 . Create a parameter constructor to initialize x and y to user supplied integers. Test the point class by creating objects and using its public functions. (b) [1 point] A triangle class to represent a triangle on the integer coordinate system. Figure 1: Triangle ABC Refer to Figure 1 above. The data to represent this triangle consists of values for coordinates of A, B, C, and area and perimeter of the triangle. Create a parameter constructor to initialize the coordinates of points A, B, and C, when the user supplies integer values for x1,y1,x2,y2,x3, and y3. Create a default constructor to initialize data members to default values. Provide get and set functions for each data member. Provide a function to calculate and set triangle area and a function to calculate and set triangle perimeter. Test the triangle class by creating objects and using its public functions. (c) [7 points] You may not use the rand() function to do this part. Using the point and triangle classes you created in previous parts, create a game. You may add additional functions to the triangle class to complete this part. i. Prompt the user for integer values for base length and height of a right angled triangle; ii. Randomly generate coordinates for point A (use uniform_int_distribution class) and calculate coordinates for points B and C using user supplied base length and height values. Create a triangle object and output the coordinates representing A, B, and C to the console; iii. Prompt the user for values for the coordinates ( x4,y4) of another point (point D) and create a point object. If point D falls within the triangle ABC, the user wins the game. Output the result of the game to the console. Keep prompting the user to re-enter coordinates for point D until the user wins the game. Print the number of attempts to win the game. Figures 2 and 3 , below, depict examples of when point D is inside triangle ABC and when it is outside, respectively. Figure 2: Point D within Triangle ABC Figure 3: Point D outside Triangle ABCStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started