feat: codewars kata object oriented piracy. test: test codewars test object oriented piracy. chore: README updated for kata

This commit is contained in:
Sandro Zimmermann 2026-03-04 17:48:45 +01:00
parent 515df4d452
commit da15c756d4
3 changed files with 23 additions and 0 deletions

View File

@ -19,3 +19,4 @@ Repository for CDS-2020 Programming and Promt Engineering II
|-|-|-|-|
|Find the force of gravity between two objects|kata_force_of_gravity.py|test_force_of_gravity.py|[5b609ebc8f47bd595e000627](https://www.codewars.com/kata/5b609ebc8f47bd595e000627/)|
|The Lamp: Revisited|kata_the_lamp.py|test_the_lamp.py|[570e6e32de4dc8a8340016dd](https://www.codewars.com/kata/570e6e32de4dc8a8340016dd)|
|OOP: Object Oriented Piracy|kata_object_oriented_piracy.py|test_object_oriented_piracy.py|[54fe05c4762e2e3047000add](https://www.codewars.com/kata/54fe05c4762e2e3047000add)|

View File

@ -0,0 +1,7 @@
class Ship:
def __init__(self, draft, crew):
self.draft = draft
self.crew = crew
def is_worth_it(self):
return self.draft - self.crew * 1.5 > 20

View File

@ -0,0 +1,15 @@
from src.codewars.kata_object_oriented_piracy import Ship
def test_piracy():
empty_ship = Ship(0, 0)
assert not empty_ship.is_worth_it()
boat = Ship(15, 20)
assert not boat.is_worth_it()
worthy_ship = Ship(100, 20)
assert worthy_ship.is_worth_it()
big_boat = Ship(35, 20)
assert not big_boat.is_worth_it()