20 lines
553 B
Python
20 lines
553 B
Python
class Ball():
|
|
def __init__(self, diameter, color):
|
|
self.diameter = diameter
|
|
self.color = color
|
|
self.timesBounced = 0
|
|
|
|
def getDiameter(self):
|
|
return self.diameter
|
|
|
|
def getColor(self):
|
|
return self.color
|
|
|
|
def getTimesBounced(self):
|
|
return self.timesBounced
|
|
|
|
def bounceBall(self):
|
|
self.timesBounced += 1
|
|
|
|
def __str__(self):
|
|
return "This ball is " + self.color + " with a diameter of " + str(self.diameter) + " and has been bounced " + str(self.timesBounced) + " times!" |