I am new to Python and I am trying to make pizza order system project. I need to create a superclass called pizza then create subclasses called Klasik and Margherita. In each subclasses I define ingredients and cost. Then when someone orders a pizze I need to get that information. Here is my code:
#create superclass
class Pizza(object):
def _init_(self, description, cost):
self.description=" "
self.cost=0
def get_description(self):
return self.description
def get_cost(self):
return self.cost
#create subclasses
class Klasik(Pizza):
def _init_(self, description, cost):
self.description = "Ingredients: cheese, olive, corn"
self.cost = 60.0
class Margherita(Pizza):
def _init_(self):
self.description="Ingredients: tomato, mozarella "
self.cost = 50.0
pizza = input("Please select 1 or 2")
if pizza=='1':
pizza=Klasik()
elif pizza=='2':
pizza=Margherita()
else :
print("Please choose between: 1 or 2")
pizza_cost = pizza.self.cost()
print("your pizza costs" + pizza_cost)
I look for attribute error pages but They are all so complicated. I looked at one of my friends codes who finished this project, we have very similar codes but when I select 1 I get
AttributeError:'Klasik' object has no attribute 'self'
Thank you