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:
def_init_(self):
selfitemCount =0 # an integer
self.totalCost =0 # intended to be a floating point number
## Adds an item to this cash register.
# @param price the price of this item
#
def addItem(self, price) :
self.itemCount = selfitemCount +1
self.totalPrice = self.totalPrice + price
## Gets the price of all items in the current sale.
# @return the total price
#
def getTotal(self):
return self.total Cost
## Gets the number of items in the current sale.
# @return the item count
#
def getCount(self) :
return selfitemCount
## Clears the item count and the total.
#
def clear(self) :
self.itemCount =0
self.totalCost =0
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?
Assume we have the following code: ## A simulated

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!