Skip to content

Commit

Permalink
Update walker_class.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 5, 2024
1 parent bef7d8c commit c499d0f
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions kyu_3/line_safari_is_that_a_line/walker_class.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
"""
Walker class: make moves, check directions, etc...
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


class Walker:
"""
Walker class: make moves, check directions, etc...
"""
"""Walker class: make moves, check directions, etc..."""

def __init__(self, grid: list):
self.__grid: list = grid
self.__is_start: bool = True
self.__position: dict = self.__get_start_point()
self.__direction = self.__set_initial_direction()

def __set_initial_direction(self) -> dict:
"""
Set initial direction.
:return: dict
"""
direction: dict = {
'left': False,
'right': False,
Expand Down Expand Up @@ -47,7 +52,8 @@ def __set_initial_direction(self) -> dict:
@property
def position(self) -> str:
"""
Return char from grid based on current position
Return char from grid based on current position.
:return: str, current char
"""
row: int = self.__position['row']
Expand All @@ -57,6 +63,7 @@ def position(self) -> str:
def move(self) -> None:
"""
Make one step if possible.

Check warning on line 66 in kyu_3/line_safari_is_that_a_line/walker_class.py

View check run for this annotation

Codecov / codecov/patch

kyu_3/line_safari_is_that_a_line/walker_class.py#L65-L66

Added lines #L65 - L66 were not covered by tests
:return: None
"""
if not self.is_done:
Expand Down Expand Up @@ -87,6 +94,7 @@ def move(self) -> None:
def is_done(self) -> bool:
"""
Check if get to the 'X' point or can make one move only.

Check warning on line 96 in kyu_3/line_safari_is_that_a_line/walker_class.py

View check run for this annotation

Codecov / codecov/patch

kyu_3/line_safari_is_that_a_line/walker_class.py#L96

Added line #L96 was not covered by tests
:return: true/false
"""
if self.__is_start:
Expand All @@ -104,6 +112,7 @@ def is_done(self) -> bool:
def __get_start_point(self) -> dict:
"""
Locate starting point.
:return: dict, starting point X
"""
result: dict = {}
Expand All @@ -130,6 +139,7 @@ def __reset_direction(self) -> None:
def position_plus(self, previous_position) -> None:
"""
Process cells if current position is +.

Check warning on line 142 in kyu_3/line_safari_is_that_a_line/walker_class.py

View check run for this annotation

Codecov / codecov/patch

kyu_3/line_safari_is_that_a_line/walker_class.py#L142

Added line #L142 was not covered by tests
:param previous_position:
:return:
"""
Expand All @@ -154,6 +164,7 @@ def position_plus(self, previous_position) -> None:
def position_minus(self, previous_position) -> None:
"""
Process cells if current position is -.

Check warning on line 166 in kyu_3/line_safari_is_that_a_line/walker_class.py

View check run for this annotation

Codecov / codecov/patch

kyu_3/line_safari_is_that_a_line/walker_class.py#L166

Added line #L166 was not covered by tests
:param previous_position:
:return:
"""
Expand All @@ -166,6 +177,7 @@ def position_minus(self, previous_position) -> None:
def position_pipe(self, previous_position) -> None:
"""
Process cells if current position is |.
:param previous_position:
:return:
"""
Expand All @@ -178,6 +190,7 @@ def position_pipe(self, previous_position) -> None:
def __set_direction(self) -> None:
"""
Update directions based on current position and previous direction.

Check warning on line 193 in kyu_3/line_safari_is_that_a_line/walker_class.py

View check run for this annotation

Codecov / codecov/patch

kyu_3/line_safari_is_that_a_line/walker_class.py#L192-L193

Added lines #L192 - L193 were not covered by tests
:return: None
"""
prev_row = self.__position['prev_row']
Expand All @@ -192,7 +205,8 @@ def __set_direction(self) -> None:

def __test_up(self) -> bool:
"""
Test u
Test up.

Check warning on line 208 in kyu_3/line_safari_is_that_a_line/walker_class.py

View check run for this annotation

Codecov / codecov/patch

kyu_3/line_safari_is_that_a_line/walker_class.py#L207-L208

Added lines #L207 - L208 were not covered by tests
:return:
"""

Check warning on line 211 in kyu_3/line_safari_is_that_a_line/walker_class.py

View check run for this annotation

Codecov / codecov/patch

kyu_3/line_safari_is_that_a_line/walker_class.py#L211

Added line #L211 was not covered by tests
row: int = self.__position['row']
Expand Down

0 comments on commit c499d0f

Please sign in to comment.