-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test solution sent via git bash #1407
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,20 @@ | ||
# write your code here | ||
from typing import List | ||
from app.players.elves.elf_ranger import ElfRanger | ||
from app.players.dwarves.dwarf_warrior import DwarfWarrior | ||
|
||
|
||
def calculate_team_total_rating(players: List[object]) -> int: | ||
total_rating = 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
for player in players: | ||
total_rating += player.get_rating() | ||
return total_rating | ||
|
||
|
||
def elves_concert(elves: List[ElfRanger]) -> None: | ||
for elf in elves: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
elf.play_elf_song() | ||
|
||
|
||
def feast_of_the_dwarves(dwarves: List[DwarfWarrior]) -> None: | ||
for dwarf in dwarves: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
dwarf.eat_favourite_dish() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from app.players.player import Player | ||
|
||
|
||
class Dwarf(Player): | ||
def __init__(self, nickname: str, favourite_dish: str) -> None: | ||
super().__init__(nickname) | ||
self._favourite_dish = favourite_dish | ||
|
||
def eat_favourite_dish(self) -> None: | ||
print(f"{self.nickname} is eating {self._favourite_dish}") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from app.players.dwarves.dwarf import Dwarf | ||
|
||
|
||
class DwarfBlacksmith(Dwarf): | ||
def __init__(self, nickname: str, | ||
favourite_dish: str, | ||
skill_level: int) -> None: | ||
super().__init__(nickname, favourite_dish) | ||
self._skill_level = skill_level | ||
|
||
def get_rating(self) -> int: | ||
return self._skill_level | ||
|
||
def player_info(self) -> str: | ||
return (f"Dwarf blacksmith {self.nickname} " | ||
f"with skill of the {self._skill_level} level") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from app.players.dwarves.dwarf import Dwarf | ||
|
||
|
||
class DwarfWarrior(Dwarf): | ||
def __init__(self, nickname: str, | ||
favourite_dish: str, | ||
hummer_level: int) -> None: | ||
super().__init__(nickname, favourite_dish) | ||
self._hummer_level = hummer_level | ||
|
||
def get_rating(self) -> int: | ||
return self._hummer_level + 4 | ||
|
||
def player_info(self) -> str: | ||
return (f"Dwarf warrior {self.nickname}. " | ||
f"{self.nickname} has a hummer of " | ||
f"the {self._hummer_level} level") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from app.players.elves.elf import Elf | ||
|
||
|
||
class Druid(Elf): | ||
def __init__(self, nickname: str, | ||
musical_instrument: str, | ||
favourite_spell: str) -> None: | ||
super().__init__(nickname, musical_instrument) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that the |
||
self._favourite_spell = favourite_spell | ||
|
||
def get_rating(self) -> int: | ||
return len(self._favourite_spell) | ||
|
||
def player_info(self) -> str: | ||
return (f"Druid {self.nickname}. " | ||
f"{self.nickname} has a favourite spell: " | ||
f"{self._favourite_spell}") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from app.players.player import Player | ||
|
||
|
||
class Elf(Player): | ||
def __init__(self, nickname: str, musical_instrument: str) -> None: | ||
super().__init__(nickname) | ||
self._musical_instrument = musical_instrument | ||
|
||
def play_elf_song(self) -> None: | ||
print(f"{self.nickname} is playing a song on the " | ||
f"{self._musical_instrument}") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from app.players.elves.elf import Elf | ||
|
||
|
||
class ElfRanger(Elf): | ||
def __init__(self, nickname: str, | ||
musical_instrument: str, | ||
bow_level: int) -> None: | ||
super().__init__(nickname, musical_instrument) | ||
self._bow_level = bow_level | ||
|
||
def get_rating(self) -> int: | ||
return 3 * self._bow_level | ||
|
||
def player_info(self) -> str: | ||
return (f"Elf ranger {self.nickname}. " | ||
f"{self.nickname} has bow of the {self._bow_level} level") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class Player(ABC): | ||
def __init__(self, nickname: str) -> None: | ||
self.nickname = nickname | ||
|
||
@abstractmethod | ||
def get_rating(self) -> int: | ||
pass | ||
|
||
@abstractmethod | ||
def player_info(self) -> str: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
calculate_team_total_rating
function should accept a list ofPlayer
objects, notobject
. Update the type hint toList[Player]
to reflect this requirement.