Class (Methods)
Python Version
class box():
def __init__(self, length, width, hight):
self.length = length
self.width = width
self.hight = hight
def get_volume(self):
return self.length * self.width * self.hight
def change_length(self):
self.length = length // 2
box_a = box(3, 2, 1)
box_b = box(4, 2, 2)
print('The volume of box_a is', box_a.get_volume())
print('The volume of box_b is', box_b.get_volume())Golang Version
Last updated