Menu

Deluxe Ice cream truck

Deluxe Ice cream truck - student project

i followed the tutorial for the deluxe ice cream code

 

class IceCream:

max_scoops = 3 # add a class attribute (introduced before)

def __init__(self):
super().__init__()
self.scoops = 0

def eat(self, scoops):
if self.scoops < scoops:
print("Not enough bites left!")
else:
self.scoops -= scoops

def add(self, scoops):
self.scoops += scoops
if self.scoops > self.max_scoops: # current step - add logic
print("Too many scoops! Dropped ice cream.")
self.scoops = 0


class IceCreamTruck: # current step - add IceCreamTruck class

def __init__(self):
super().__init__()
self.sold = 0

def order(self, scoops):
ice_cream = IceCream()
self.add(ice_cream, scoops)
return ice_cream

def add(self, ice_cream, scoops):
ice_cream.add(scoops)
self.sold += scoops

class DeluxeIceCreamTruck(IceCreamTruck):
def order(selff, scoops):
ice_cream = super().order(scoops)
ice_cream.add(1)
return ice_cream