Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!