Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Problems with inheritance with classes
#1
I'm getting a type error.
I want to write a subclass and add an attribute to it, then write a method to display the attribute and call the method.

Class Restaurant ():

def __init__(self, restaurant_name, cuisine_name):
self.restaurant_name = restaurant_name
self.cuisine_name = cuisine_name

def describe_restaurant (self):
print("This is " + self.restaurant name.title())
print(self.cuisine_name.title() + " is the only cuisine right now")

def open_restaurant(self):
print(self.restaurant_name.title() + " is open for business ")

class IceCreamStand(Restaurant):

def __init__(self, restaurant_name, cuisine_name):
super().__init__(restaurant_name, cuisine_name)
self.flavors = flavors

def print_flavors(self):
print(self.flavors)

IceCream = IceCreamStand('dominos', 'pizza', 'BBQ')

IceCream.IceCreamStand.print_flavors()
So basically, I have a class Restaurant and I have a subclass IceCreamStand and I added an attribute flavors to the subclass and a method print_flavors to display the flavors, then I have to call the method.

The specific error I get is TypeError: __init__ takes 3 positional arguments but 4 were given.
Any help would be appreciated.
Quote

Top Page

Messages In This Thread
Problems with inheritance with classes - by internetguy - Jun-15-2019, 07:47 AM

Possibly Related Threads...
Thread Author Replies Views Last Post
  Unexpected Output using classes and inheritance langley 2 359 Jul-04-2019, 09:33 AM
Last Post: langley
  Multiple Inheritance - Help pls! magnusbrigido 1 355 May-17-2019, 12:56 PM
Last Post: ichabod801
  Multiple inheritance - the right way ? denis_beurive 6 914 Feb-14-2019, 09:24 AM
Last Post: denis_beurive
  Inheritance Athul 7 994 Aug-11-2018, 06:48 PM
Last Post: yksingh1097
  Using Dictionaries in inheritance feduser 2 819 Jun-21-2018, 08:31 PM
Last Post: volcano63
  inheritance Arifattal 3 1,184 Jan-15-2018, 02:52 PM
Last Post: Arifattal
  Problems with importing classes in different folder Xeraphim 3 1,158 Nov-08-2017, 03:20 PM
Last Post: Larz60+
  Using classes? Can I just use classes to structure code? muteboy 5 1,662 Nov-01-2017, 04:20 PM
Last Post: metulburr

Forum Jump:


Users browsing this thread: 1 Guest(s)