Task 6 Write a class called Triangle with the required constructor and methods to get the following output. Subtasks: 1. Create a class called Triangle. 2. Create the required constructor. Use Encapsulation to protect the variables. [Hint: Assign the variables in private) 3. Create getBase(), gettoight(), setBase and seteight|) method to access variables. 4. Create a method called area to calculate the area of triangles. 5. Handle the operator overloading by using a special method to calculate the radius and area of triangle 3. You are not allowed to change the code below] Write your code here for subtasks 1-5 11 = Triangle(10, 5) print("First Triangle Base:" , t1.getBase()) print(First Triangle Height:" , t1.getHeight|()) print"First Triangle area:" ,1.area()) Output: First Triangle Base: 10 First Triangle Height: 5 First Triangle area: 25.0 Second Triangle Base: 5 Second Triangle Height: 3 Second Triangle area: 7.5 Third Triangle Base: 5 Third Triangle Height: 2 Third Triangle area: 5.0 12 = Triangle(5, 3) print("Second Triangle Base:" , 12.getBase()) printSecond Triangle Height" , 12.getHeight()) printSecond Triangle area:",12.area() 13 - t1 - 12 print("Third Triangle Base:" , 13.getBase()) print("Third Triangle Height." , 13.getHeight()) print("Third Triangle area:" ,13.area())
Task 6 Write a class called Triangle with the required constructor and methods to get the following output. Subtasks: 1. Create a class called Triangle. 2. Create the required constructor. Use Encapsulation to protect the variables. [Hint: Assign the variables in private) 3. Create getBase(), gettoight(), setBase and seteight|) method to access variables. 4. Create a method called area to calculate the area of triangles. 5. Handle the operator overloading by using a special method to calculate the radius and area of triangle 3. You are not allowed to change the code below] Write your code here for subtasks 1-5 11 = Triangle(10, 5) print("First Triangle Base:" , t1.getBase()) print(First Triangle Height:" , t1.getHeight|()) print"First Triangle area:" ,1.area()) Output: First Triangle Base: 10 First Triangle Height: 5 First Triangle area: 25.0 Second Triangle Base: 5 Second Triangle Height: 3 Second Triangle area: 7.5 Third Triangle Base: 5 Third Triangle Height: 2 Third Triangle area: 5.0 12 = Triangle(5, 3) print("Second Triangle Base:" , 12.getBase()) printSecond Triangle Height" , 12.getHeight()) printSecond Triangle area:",12.area() 13 - t1 - 12 print("Third Triangle Base:" , 13.getBase()) print("Third Triangle Height." , 13.getHeight()) print("Third Triangle area:" ,13.area())
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education