Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 KB | None | 0 0
  1. import classes
  2. import numpy as np
  3.  
  4. class Calcylator:
  5.    
  6.     def __init__(self, command = "gogo"):
  7.         self.command = command
  8.  
  9.     def exit_calc(self, action_list):
  10.  
  11.         #print(len(action_list[0][:]))
  12.         #print(len(action_list[:]))
  13.     #  
  14.         #print(action_list[:][0])
  15.         for x in action_list[:][0]:
  16.             print(x)
  17.         print("result!!!!!!!!!!!!!!!!!")
  18.         #fixa utskriftsgrejjen vid avslut
  19.  
  20.     def run_calc(self):
  21.         print("fuckrunt med listan")
  22.         action_list = []
  23.  
  24.        
  25.         def reg_printer(self, index):
  26.             print(action_list[index].value)
  27.  
  28.  
  29.  
  30.         def wait_for_command(self):
  31.             self.command = input("enter commands please :")
  32.  
  33.  
  34.  
  35.         def execute_command(self):
  36.             print("execute commando: " + self.command)
  37.             inputList = self.command.split()
  38.            
  39.             if ( len(inputList) == 3 ):
  40.                 print("hanterar 3 inputs")
  41.                
  42.  
  43.                 temp_reg = classes.Register(inputList[0])
  44.                 temp_val = classes.Value((inputList[2]))
  45.                 temp_ope = classes.Operation(inputList[1], temp_reg, temp_val)
  46.                 action_list.append((temp_reg, temp_ope, temp_val))
  47.  
  48.                
  49.  
  50.             elif (inputList[0].lower() == "quit"):
  51.                 print("hanterar 1 quit")
  52.             elif (inputList[0].lower() == "print"):
  53.                 print("hanterar print")
  54.  
  55.                 temp_reg = classes.Register(inputList[0])
  56.  
  57.                 action_list.append(("print", temp_reg, 0 ))
  58.                
  59.             else:
  60.                 print("fel input, gör om gör rätt")
  61.            
  62.            
  63.            
  64.         print("Välkommen till Kalkylatorn!\n\n")
  65.    
  66.         while (self.command.lower() != 'quit'):
  67.            
  68.            
  69.             wait_for_command(self)
  70.             execute_command(self)
  71.  
  72.         Calcylator.exit_calc(self,action_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement