Question: Writing a cash register program with python. The program is not adding the items but just displaying the price of the first it. This is
Writing a cash register program with python. The program is not adding the items but just displaying the price of the first it.
This is where I think the error is but I am not sure what I need to do to change this?
def get_total(self):
price = 0.0
for item in self.__list_item:
price += item.get_price()
return price


class Retailitem def -init-(self, des, UI, price) : self. description - des self. units inventory - UI self. price price def set desc (self, desc) self. description= des def set_UI (self, UI) self. units inventory - UI def set price (self,price) self. price price def get desc (self) return self. description def get UI (self) return self. units inventory get price (self) return float (self. price) class CashRegister: def -init-(self): self. list item - [] - def purchase item (self, r) self. list item.append (r) def get total (self) price 0.0 for item in self. list item: price item.get_price ) return price def show items (self): for item in self. list item: print (item.get_desc)) def clear (self): for item in self. list item: self. list item. remove (item) def main ()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
