Advertisement
carisa

Untitled

Mar 30th, 2020
1,967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Browser:
  2.     def _init_(self):
  3.         self.__forward = []
  4.         self.__current_url = []
  5.         self.__backward = []
  6.  
  7.     def new_url(self,new_url):
  8.         if len(self.__current_url) == 0:
  9.             self.__current_url.append(new_url)
  10.         else:
  11.             self._backward.append(self._current_url[-1])
  12.             self.__current_url.pop()
  13.             self.__current_url.append(new_url)
  14.         return self.__current_url[-1]
  15.  
  16.     def backwards(self):
  17.         if len(self.__backward)  == 0:
  18.             return None
  19.         else:
  20.             self._forward.append(self._current_url[-1])
  21.             self._current_url.append(self._backward[-1])
  22.             self.__backward.pop()
  23.             self.__current_url.pop(0)
  24.         return self.__current_url[-1]
  25.  
  26.     def  forward(self):
  27.         if len(self.__forward)  == 0:
  28.             return None
  29.         else:
  30.             self._backward.append(self._current_url[-1])
  31.             self._current_url.append(self._forward[-1])
  32.             self.__forward.pop()
  33.             self.__current_url.pop(0)
  34.         return self.__current_url[-1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement