Facebook
From Ample Cockroach, 3 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 67
  1.  
  2. class Node:
  3.     def __init__(self,addr):
  4.         self.addr=addr
  5.         self.next=None
  6.         self.back=None
  7.    
  8. class WebBrowser2:
  9.  
  10.  
  11.     def __init__(self):
  12.         self.homeAddr = 'www.hufs.ac.kr'
  13.         self.head = Node(self.homeAddr)
  14.         self.tail=Node(None)
  15.         self.head.back=None
  16.         self.head.next=self.tail
  17.         self.tail.back=self.head
  18.         self.tail.next=None
  19.         self.current = self.head
  20.  
  21.  
  22.  
  23.     def forward(self):
  24.         if self.current.next is not None:
  25.             self.current=self.current.next
  26.             print(self.current.addr)
  27.        
  28.  
  29.     def backward(self):
  30.         if self.current!=self.head:
  31.             self.current=self.current.back
  32.             print(self.current.addr)
  33.            
  34.     def go(self,addr):
  35.         location=Node(addr)
  36.         self.current.next=location
  37.         location.back=self.current
  38.         self.current=location
  39.         print(addr)
  40.  
  41.  
  42.        
  43.     def history(self):
  44.         node=self.tail
  45.         while node is self.head:
  46.             print(node.addr)
  47.             node=node.back
  48.            
  49.         '''
  50.        result=[]
  51.        cur=self.tail
  52.        while cur.back.back:
  53.            cur=cur.back
  54.            result.append(cur.addr)
  55.        print(result)
  56.        '''
  57.         '''
  58.        ptr=self.head.back
  59.        while ptr is not self.head:
  60.            print(ptr.addr)
  61.            prt=ptr.back
  62.            
  63.         '''  
  64.         '''
  65.        while node is not None:
  66.            print(node.addr)
  67.            node=node.next
  68.             '''
  69.  
  70.        
  71.            
  72.            
  73. w=WebBrowser2()
  74.  
  75. command=[]
  76. while True:
  77.     A=input()
  78.     if A=='quit':break
  79.     command.append(A.split())
  80. n=len(command)
  81.  
  82. print(w.homeAddr)
  83.  
  84. for i in range(n):
  85.  
  86.     if(command[i][0]=='forward'):
  87.         w.forward()
  88.     elif command[i][0]=='backward':
  89.         w.backward()
  90.     elif command[i][0]=='go':
  91.         w.go(command[i][1])
  92.     elif command[i][0]=='history':
  93.         w.history()
  94.  

Replies to Untitled rss

Title Name Language When
Re: Untitled Big Hog python 3 Years ago.