From 110f298bbfd2f3b3e4bbdaaa72c18ceaa483d8f6 Mon Sep 17 00:00:00 2001 From: hizlanarif Date: Sat, 6 Jun 2026 16:24:39 +0200 Subject: [PATCH] aufgabe-3 classy --- README.md | 13 +++---------- src/oop_solution.py | 16 ++++++---------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3241d8d..a431484 100644 --- a/README.md +++ b/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. \ No newline at end of file diff --git a/src/oop_solution.py b/src/oop_solution.py index 5ff1290..9cbfecb 100644 --- a/src/oop_solution.py +++ b/src/oop_solution.py @@ -1,12 +1,8 @@ -class Human: +class Animal: + def __init__(self, name:str): + self.name=name - def __init__(self, name: str): - self.name = name -class Man(Human): - pass +class Cat(Animal): -class Woman(Human): - pass - -def God(): - return [Man("Adam"), Woman("Eve")] \ No newline at end of file + def speak(self) -> str: + return f"{self.name} meows." \ No newline at end of file