Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

cashier program with class python

1## 
 2#  This module defines the CashRegister class.
 3#
 4
 5## A simulated cash register that tracks the item count and the total amount due.
 6#
 7class CashRegister :
 8   ## Constructs a cash register with cleared item count and total.
 9   #
10   def __init__(self) :
11      self._itemCount = 0
12      self._totalPrice = 0.0
13      
14   ## Adds an item to this cash register.
15   #  @param price the price of this item
16   #
17   def addItem(self, price) :
18      self._itemCount = self._itemCount + 1
19      self._totalPrice = self._totalPrice + price 
20      
21   ## Gets the price of all items in the current sale.
22   #  @return the total price
23   #
24   def getTotal(self) :
25      return self._totalPrice
26      
27   ## Gets the number of items in the current sale.
28   #  @return the item count
29   #
30   def getCount(self) :
31      return self._itemCount
32
33   ## Clears the item count and the total.
34   #  
35   def clear(self) :
36      self._itemCount = 0
37      self._totalPrice = 0.0
Comment

PREVIOUS NEXT
Code Example
Python :: python event emitter 
Python :: Which of the following is not a core data type in Python programming? 
Python :: DOWNLOAD ANALYZE_DXP.PY 
Python :: How to secure an endpoint for selected users with Flask-JWT-Extended 
Python :: HTML not being displayed properly in Flask, Python 
Python :: docstring python pycharm 
Python :: cuenta atras segundero python 
Python :: jsfakjfkjadjfksajfa 
Python :: cyclic rotation python 
Python :: check if id is present in elasticsearch using python 
Python :: parseint python equivalent 
Python :: replace string in dictionary python 
Python :: ring load the odbclib.ring library 
Python :: hacer un programa en python ingresar números enteros obtenga el segundo valor máximo 
Python :: python run unix command 
Python :: Python loop aray 
Python :: sumy library 
Python :: dic to dic arrays must all be same length 
Python :: how to add list toa key in ict 
Python :: colorgram.py 1.2.0 
Python :: axes increase fonsize of values python 
Python :: dataflair python 
Python :: login system read data python 
Python :: nunique sort 
Python :: https://raw.githubusercontent.com/tim-yao/lighthouse-ci/d32f465bb6cda08ded4ce25c88c43a3103e4940a/.browserslistrc 
Python :: for c in range python 
Python :: python documentacion comentarios 
Python :: python strong type 
Python :: deploy vue app to google cloud run 
Python :: loop until counted to 100 forever 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =