2728. Count Houses in a Circular Street
You are given an object
street
of classStreet
that represents a circular street and a positive integerk
which represents a maximum bound for the number of houses in that street (in other words, the number of houses is less than or equal tok
). Houses’ doors could be open or closed initially.Initially, you are standing in front of a door to a house on this street. Your task is to count the number of houses in the street.
The class
Street
contains the following functions which may help you:
void openDoor()
: Open the door of the house you are in front of.void closeDoor()
: Close the door of the house you are in front of.boolean isDoorOpen()
: Returnstrue
if the door of the current house is open andfalse
otherwise.void moveRight()
: Move to the right house.void moveLeft()
: Move to the left house.Return
ans
which represents the number of houses on this street.
1 | /** |