aufgabe-3 classy

This commit is contained in:
Arif Hizlan 2026-06-06 16:24:39 +02:00
parent 7624caaf6c
commit 110f298bbf
2 changed files with 9 additions and 20 deletions

View File

@ -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.

View File

@ -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."