kuis oop dicoding

udah bener, tp pas di submit gagal karna method deskripsi hrs return itu....
mail@pastecode.io avatar
unknown
python
7 months ago
664 B
0
Indexable
Never
class Animal:
    def __init__(self, name, age, species):
        self.name = name
        self.age = age
        self.species = species


animal_a = Animal("Neko", 3, "Persian")


class Cat(Animal):
    def deskripsi(self):
        self.name = ("'" + animal_a.name + " adalah kucing berjenis "
                     + animal_a.species + " yang sudah berumur "
                     + str(animal_a.age) + " tahun" + "'")
        return (self.name)

    def suara():
        return ("meow!")


# print(Cat.suara())
print(Cat.deskripsi(self=Cat))

myCat = Cat("name", 3, "Persian")
myCat.name = "Neko"
myCat.age = 3
myCat.species = "Persian"
Leave a Comment