Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Browser:
- def _init_(self):
- self.__forward = []
- self.__current_url = []
- self.__backward = []
- def new_url(self,new_url):
- if len(self.__current_url) == 0:
- self.__current_url.append(new_url)
- else:
- self._backward.append(self._current_url[-1])
- self.__current_url.pop()
- self.__current_url.append(new_url)
- return self.__current_url[-1]
- def backwards(self):
- if len(self.__backward) == 0:
- return None
- else:
- self._forward.append(self._current_url[-1])
- self._current_url.append(self._backward[-1])
- self.__backward.pop()
- self.__current_url.pop(0)
- return self.__current_url[-1]
- def forward(self):
- if len(self.__forward) == 0:
- return None
- else:
- self._backward.append(self._current_url[-1])
- self._current_url.append(self._forward[-1])
- self.__forward.pop()
- self.__current_url.pop(0)
- return self.__current_url[-1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement