diff --git a/README.md b/README.md index df20fc2..3241d8d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,10 @@ -# Assignment 2 - Caesar Cipher +# Assignment 3 - Adam & Eve Subclasses -This is my code for the OOP homework. I chose the Caesar Cipher Helper. +This is my code for the Task 3 assignment using inheritance. -- **Link:** https://www.codewars.com/kata/526d42b6526963598d0004db +- **Link:** https://www.codewars.com/kata/547274e24481cfc469000416 ### How it works: -- The `CaesarCipher` class takes a `shift` number. -- `encode` changes text to uppercase and moves letters forward. It uses `% 26` so letters stay in the A-Z alphabet. -- `decode` moves letters backward to fix the text. -- Spaces and punctuation do not change. - -### Tools: -I set up black and ruff with pre-commit hooks. They check and fix my code format before every commit. \ No newline at end of file +- 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. diff --git a/src/oop_solution.py b/src/oop_solution.py index 42ea9a5..5ff1290 100644 --- a/src/oop_solution.py +++ b/src/oop_solution.py @@ -1,25 +1,12 @@ -class CaesarCipher: +class Human: - def __init__(self, shift: int): - self.shift = shift - self.alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + def __init__(self, name: str): + self.name = name +class Man(Human): + pass - def encode(self, st: str) -> str: - result = [] - for char in st.upper(): - if char in self.alphabet: - new_index = (self.alphabet.index(char) + self.shift) % 26 - result.append(self.alphabet[new_index]) - else: - result.append(char) - return "".join(result) +class Woman(Human): + pass - def decode(self, st: str) -> str: - result = [] - for char in st.upper(): - if char in self.alphabet: - new_index = (self.alphabet.index(char) - self.shift) % 26 - result.append(self.alphabet[new_index]) - else: - result.append(char) - return "".join(result) \ No newline at end of file +def God(): + return [Man("Adam"), Woman("Eve")] \ No newline at end of file