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
|
The `Animal` base class sets up the `name` attribute.
|
||||||
|
- The `Cat` class inherits from `Animal` so it automatically gets the name property.
|
||||||
This is my code for the Task 3 assignment using inheritance.
|
- I added the `speak` method to the `Cat` class to make it return a str.
|
||||||
|
|
||||||
- **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.
|
|
||||||
@ -1,12 +1,8 @@
|
|||||||
class Human:
|
class Animal:
|
||||||
|
def __init__(self, name:str):
|
||||||
|
self.name=name
|
||||||
|
|
||||||
def __init__(self, name: str):
|
class Cat(Animal):
|
||||||
self.name = name
|
|
||||||
class Man(Human):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class Woman(Human):
|
def speak(self) -> str:
|
||||||
pass
|
return f"{self.name} meows."
|
||||||
|
|
||||||
def God():
|
|
||||||
return [Man("Adam"), Woman("Eve")]
|
|
||||||
Loading…
x
Reference in New Issue
Block a user