Question: Assume we have the following code: ## A simulated cash register that tracks the item count and the total amount due. # class CashRegister: def
Assume we have the following code:
## A simulated cash register that tracks the item count and the total amount due.
#
class CashRegister:
definitself:
selfitemCount # an integer
self.totalCost # intended to be a floating point number
## Adds an item to this cash register.
# @param price the price of this item
#
def addItemself price :
self.itemCount selfitemCount
self.totalPrice self.totalPrice price
## Gets the price of all items in the current sale.
# @return the total price
#
def getTotalself:
return self.total Cost
## Gets the number of items in the current sale.
# @return the item count
#
def getCountself :
return selfitemCount
## Clears the item count and the total.
#
def clearself :
self.itemCount
self.totalCost
a Write the comment and implementation of a 'getDollars' method that returns the amount of the total sale as a dollar value without the cents.
b Is the getDollars method above an accessor or a mutator?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
