aufgabe-3 classy
This commit is contained in:
parent
7624caaf6c
commit
110f298bbf
13
README.md
13
README.md
@ -1,10 +1,3 @@
|
||||
# Assignment 3 - Adam & Eve Subclasses
|
||||
|
||||
This is my code for the Task 3 assignment using inheritance.
|
||||
|
||||
- **Link:** https://www.codewars.com/kata/547274e24481cfc469000416
|
||||
|
||||
### How it works:
|
||||
- I created a base class called `Human`.
|
||||
- `Man` and `Woman` are subclasses that inherit everything from `Human`.
|
||||
- The `God` function creates and returns an array with the first man and woman.
|
||||
The `Animal` base class sets up the `name` attribute.
|
||||
- The `Cat` class inherits from `Animal` so it automatically gets the name property.
|
||||
- I added the `speak` method to the `Cat` class to make it return a str.
|
||||
@ -1,12 +1,8 @@
|
||||
class Human:
|
||||
|
||||
class Animal:
|
||||
def __init__(self, name:str):
|
||||
self.name=name
|
||||
class Man(Human):
|
||||
pass
|
||||
|
||||
class Woman(Human):
|
||||
pass
|
||||
class Cat(Animal):
|
||||
|
||||
def God():
|
||||
return [Man("Adam"), Woman("Eve")]
|
||||
def speak(self) -> str:
|
||||
return f"{self.name} meows."
|
||||
Loading…
x
Reference in New Issue
Block a user