Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please create the following program in c++ Please carefully read through all the instructions. 5. Any class you create must not have any public data

Please create the following program in c++

Please carefully read through all the instructions.

image text in transcribed

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 ABC

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

What is the foreign bond market of a country?

Answered: 1 week ago

Question

5. Do you have any foreign language proficiency?

Answered: 1 week ago