You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.6 KiB

VOWELS = "aeiou"
class User:
def __init__(self, name): = name = None
def connect_on_chat(self, o_chat): = o_chat
def send(self, text): += "{} said: {}\n".format(, text)
robot_text = text.lower()
robot_text = "".join(["0" if x in VOWELS else "1" for x in robot_text]) += "{} said: {}\n".format(, robot_text)
class Human(User):
class Robot(User):
class Chat:
def __init__(self):
self.human_chat = ""
self.robot_chat = ""
def connect_human(self, human: Human):
def show_human_dialogue(self) -> str:
return self.human_chat.strip('\n')
def connect_robot(self, robot: Robot):
def show_robot_dialogue(self) -> str:
return self.robot_chat.strip('\n')
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary for auto-testing
chat = Chat()
karl = Human("Karl")
bot = Robot("R2D2")
karl.send("Hi! What's new?")
bot.send("Hello, human. Could we speak later about it?")
assert chat.show_human_dialogue() == """Karl said: Hi! What's new?
R2D2 said: Hello, human. Could we speak later about it?"""
assert chat.show_robot_dialogue() == """Karl said: 101111011111011
R2D2 said: 10110111010111100111101110011101011010011011"""
print("Coding complete? Let's try tests!")