Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If programming a class to represent a geometry calculator, which class containing methods with parameters could be used to calculate the area of a circle

If programming a class to represent a geometry calculator, which class containing methods with parameters could be used to calculate the area of a circle with radius r; the area of a square with length l and width w; and increment the total number of calculations performed?
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def area_of_circle(self,r):
self.numOfCalcs +=1
return math.pi * r * r
def area_of_square(self,l,w):
self.numOfCalcs +=1
return l * w
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def area_of_circle(self):
self.numOfCalcs +=1
return math.pi * r * r
def area_of_square(self):
self.numOfCalcs +=1
return l * w
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def area_of_circle(self,r):
numOfCalcs +=1
return math.pi * r * r
def area_of_square(self,l,w):
numOfCalcs +=1
return l * w
class Geo_Calc:
def __init__(self):
self.numOfCalcs =0
def clearTotal(self):
self.numOfCalcs =0
def returnTotal(self):
return self.numOfCalcs
def area_of_circle(self):
numOfCalcs +=1
return math.pi * r * r
def area_of_square(self):
numOfCalcs +=1
return l * w

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

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions