Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I'm having a real had time with the RuntimeError aspect of this question. Can anyone help me, promise to upvote if solution works. MUST

Hi, I'm having a real had time with the RuntimeError aspect of this question. Can anyone help me, promise to upvote if solution works. MUST BE IN PYTHON!!

image text in transcribed

13.11 (The Triangle class) Modify the Triangle class in Programming Exercise 12.1 to throw a RuntimeError exception if the three given sides cannot form a triangle. 12.1 (The Triangle class) Design a class named Triangle that extends the GeometricObject class. The Triangle class contains: Three float data fields named sidel, side2, and side3 to denote the three sides of the triangle. A constructor that creates a triangle with the specified sidel, side2, and side3 with default values 1.0. The accessor methods for all three data fields. A method named getAreaO that returns the area of this triangle. A method named getPerimeter that returns the perimeter of this triangle. A method named str O that returns a string description for the triangle. For the formula to compute the area of a triangle, see Exercise 2.14. The _str-O method is implemented as follows: return "Triangle: sidelstr(sidel)side2+ Draw the UML diagrams for the classes Triangle and Geometricobject. Implement the Triangle class. Write a test program that prompts the user to enter the three sides of the triangle, a color, and 1 or 0 to indicate whether the tri- angle is filled. The program should create a Triangle object with these sides and set the color and filled properties using the input. The program should display the triangle's area, perimeter, color, and True or False to indicate whether the trian- gle is filled or not. 2.14 (Geometry: area ofa triangle) Write a program that prompts the user to enter the three points (x1, y), Cx2, y2), and (x3, y3) of a triangle and displays its area. The formula for computing the area of a triangle is s (sidelside2 +side3)/2 area Vs -side1s side2s side3) Here is a sample run: Enter three points for a triangle: 1.5, 3.4, 4.6, , 9.5, -3.4 The area of the triangle is 33.6 13.11 (The Triangle class) Modify the Triangle class in Programming Exercise 12.1 to throw a RuntimeError exception if the three given sides cannot form a triangle. 12.1 (The Triangle class) Design a class named Triangle that extends the GeometricObject class. The Triangle class contains: Three float data fields named sidel, side2, and side3 to denote the three sides of the triangle. A constructor that creates a triangle with the specified sidel, side2, and side3 with default values 1.0. The accessor methods for all three data fields. A method named getAreaO that returns the area of this triangle. A method named getPerimeter that returns the perimeter of this triangle. A method named str O that returns a string description for the triangle. For the formula to compute the area of a triangle, see Exercise 2.14. The _str-O method is implemented as follows: return "Triangle: sidelstr(sidel)side2+ Draw the UML diagrams for the classes Triangle and Geometricobject. Implement the Triangle class. Write a test program that prompts the user to enter the three sides of the triangle, a color, and 1 or 0 to indicate whether the tri- angle is filled. The program should create a Triangle object with these sides and set the color and filled properties using the input. The program should display the triangle's area, perimeter, color, and True or False to indicate whether the trian- gle is filled or not. 2.14 (Geometry: area ofa triangle) Write a program that prompts the user to enter the three points (x1, y), Cx2, y2), and (x3, y3) of a triangle and displays its area. The formula for computing the area of a triangle is s (sidelside2 +side3)/2 area Vs -side1s side2s side3) Here is a sample run: Enter three points for a triangle: 1.5, 3.4, 4.6, , 9.5, -3.4 The area of the triangle is 33.6

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

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

Students also viewed these Databases questions

Question

3. Why does the aggregate demand curve slope downward? LOP8

Answered: 1 week ago