I am trying to make a program with loads of films where i can call them using Classes (I am very new to classes and still trying to figure out how they work). Is there a way I can create the function for the bottom 3 lines that can does this automatically? Kind of like the Get functions I have put in, I tried imbedding this into one function but got the error code that the functions where not defined.
class Film():
def __init__(self, name, genre, rating):
self.name = name
self.genre = genre
self.rating = rating #0-100
def get_name(self):
return ("The Name of the film is: " + str(self.name))
def get_genre(self):
return ("The Genre of the film is: " + str(self.genre))
def get_rating(self):
return ("The rating of the film is: " + str(self.name))
f1 = Film("Fight Club", "Thriller", 91)
f2= Film("Whiplash","Thriller",86)
f3 = Film("Inside out","Animation",71)
print(f1.get_name(), f1.get_genre(), f1.get_rating())
print(f2.get_name(), f2.get_genre(), f2.get_rating())
print(f3.get_name(), f3.get_genre(), f3.get_rating())