21 lines
374 B
Python
21 lines
374 B
Python
|
class Ball:
|
||
|
__diameter__ = 0.0
|
||
|
|
||
|
## Methods
|
||
|
# Constructor
|
||
|
def __init__(self, diameter = 1.0):
|
||
|
self.__diameter__ = diameter
|
||
|
pass
|
||
|
|
||
|
# a simple method
|
||
|
def introduction(self):
|
||
|
print(f"My diameter is {self.__diameter__:.3f}.")
|
||
|
pass
|
||
|
|
||
|
# main code
|
||
|
a = Ball()
|
||
|
b = Ball(2.0)
|
||
|
|
||
|
a.introduction()
|
||
|
b.introduction()
|