2017-07-30 86 views
-3

你好我有一個Python代碼,不斷給我一個錯誤,有人可能會繼續之前看它。這是我的python類來計算手機話費的金額。我現在有這個但它不返回價值類的Python代碼不返回值

經濟計劃包括$ 30無限的語音和文字,1 GB數據爲10美元,每GB超過6美元。

正常計劃包括$ 30無限的語音和文字,5 GB數據爲30美元,每GB超過4美元。

class cellphone: 
    cost = 30 
    due = 0 
    amountGB = 0 
    Total = 0 

    def econPlan (self, gB, gbOver): 
     self.cost = 30 
     self.gB = 1 
     self.gbOver = 6 
     self.due = 0 

     while amountGB >= self.gB: 
      int(amountGB - self.gB)* self.gbOver 
     return self.due 

     while cPlan == Econ and amountGB >= self.gB: 
      print ("$",self.due) 

    def normPlan (self, gB, gbOver): 
     self.cost = 30 
     self.gB = 5 
     self.gbOver = 4 

     while amountGB >= self.gB: 
      int(amountGB - self.gB)* self.gbOver 
     return self.due 

     while cPlan == Norm and amountGB >= self.gB: 
      print ("$",self.due) 






print (" Which Plan do you have: econ or norm?") 
print (" Econ is $30 unlimited voice and text, 1 GB data for $10, and $6 for every GB over.") 
print (" Norm is $30 unlimited voice and text, 5 GB data for $30, and $4 for every GB over.") 

econ = cellphone.econPlan 
norm = cellphone.normPlan 
cellphone.cPlan = input ("So which plan do you have? >>") 
if cellphone.cPlan == econ: 
    print ("you have the Economy plan") 

elif cellphone.cPlan == norm: 
    print ("you have the Normal plan") 

cellphone.amountGB = input ("how many GB did you used >>") 
if cellphone.cPlan == "Econ": 
    print (cellphone.due) 
+2

發佈錯誤... –

+2

什麼是錯誤? –

+0

「自我」在哪裏? –

回答

0

自我只有方法中存在。如果您想要獲取方法內的變量的當前值,請調用該方法並返回該變量。