示例#1
0
文件: main.py 项目: bzumik1/svao_01
def main():
    # Cesar cipher
    print(Color.BOLD + "CESAR CIPHER" + Color.END)
    message = "hi, how are you?"
    key = 825
    # Encoding
    print(f"{Color.UNDERLINE}Encoding:{Color.END}")
    print(f"\tEncrypting message {Color.BOLD}{message}{Color.END} with key {Color.BOLD}{key}{Color.END}")
    encrypted_message = CeasarCipher.encode(message, key)
    print(f"\tEncrypted message is {Color.BOLD}{encrypted_message}{Color.END}")
    #Decoding
    print(f"{Color.UNDERLINE}Decoding:{Color.END}")
    print(f"\tDecrypting message {Color.BOLD}{encrypted_message}{Color.END} with key {Color.BOLD}{key}{Color.END}")
    decrypted_message = CeasarCipher.decode(encrypted_message, key)
    print(f"\tDecrypted message is {Color.BOLD}{decrypted_message}{Color.END}")

    print("\n\n")
    # Rock, paper, scissors
    print(Color.BOLD + "ROCK, PAPER, SCISSORS GAME" + Color.END)
    player1 = Player(0.1, 0.4, 0.5)
    player2 = Player(0.3, 0.3, 0.4)
    GameRPS.play_rsp(player1, player2, 3)
示例#2
0
 def test_decodes_message_with_special_character(self):
     self.assertEqual(CeasarCipher.decode("Ij, ipx bsf zpv?", 1),
                      "hi, how are you?")
示例#3
0
 def test_decodes_message_with_capital_letter(self):
     self.assertEqual(CeasarCipher.decode("BCD", 1), "abc")
示例#4
0
 def test_decodes_message_from_end_of_alphabet(self):
     self.assertEqual(CeasarCipher.decode("XYZABCDEFGHIJKLMNOPQRSTUVW", 23),
                      "abcdefghijklmnopqrstuvwxyz")
示例#5
0
 def test_decodes_message_from_start_of_alphabet(self):
     self.assertEqual(CeasarCipher.decode("bcd", 1), "abc")