DONE04 si pas de chiffre: avance de 1|TP_3.9|ROBOC

This commit is contained in:
Fred Z 2018-02-15 11:00:12 +01:00
parent 44e6ab60a6
commit 3500192083

View File

@ -51,14 +51,12 @@ class Map:
>>> TestMap.move_to("E4") >>> TestMap.move_to("E4")
4 4
>>> MiniMap.move_to("O1") >>> MiniMap.move_to("O")
1 1
>>> MiniMap.move_to("Z1") >>> MiniMap.move_to("Z1")
0 0
>>> MiniMap.move_to("4") >>> MiniMap.move_to("4")
0 0
>>> MiniMap.move_to("N")
0
>>> MiniMap.move_to("E1") >>> MiniMap.move_to("E1")
2 2
>>> MiniMap.map_print() >>> MiniMap.map_print()
@ -135,21 +133,23 @@ class Map:
:return: une cle de la constante MOVE_STATUS :return: une cle de la constante MOVE_STATUS
""" """
# decompose le mouvement # decompose le mouvement
try: try: # on recupere le 1er caractere (la direction)
direction = move[0] direction = move[0]
except IndexError as except_detail: except IndexError as except_detail:
# print("IndexError: «{}»".format(except_detail)) print("IndexError: «{}»".format(except_detail))
return 0 # return 0
except TypeError as except_detail: except TypeError as except_detail:
print("TypeError: «{}»-«{}»".format(except_detail, move)) print("TypeError: «{}»-«{}»".format(except_detail, move))
# return 0 # return 0
# TODO04 si pas de chiffre, on avance d'une unite if len(move[1:]) > 0: # on recupere les caractere suivants (dist)
try: try:
goal = int(move[1:]) goal = int(move[1:])
except ValueError as except_detail: except ValueError as except_detail:
# print("ValueError: «{}»".format(except_detail)) # print("ValueError: «{}»".format(except_detail))
return 0 return 0
else: # si pas de chiffre, on avance d'une seule unite
goal = 1
steps = 0 steps = 0
# direction non conforme # direction non conforme