feat: codewars kata object oriented piracy. test: test codewars test object oriented piracy. chore: README updated for kata
This commit is contained in:
parent
515df4d452
commit
da15c756d4
@ -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)|
|
||||
|
||||
7
src/codewars/kata_object_oriented_piracy.py
Normal file
7
src/codewars/kata_object_oriented_piracy.py
Normal 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
|
||||
15
tests/codewars/test_object_oriented_piracy.py
Normal file
15
tests/codewars/test_object_oriented_piracy.py
Normal 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()
|
||||
Loading…
x
Reference in New Issue
Block a user