## Question

## Transcribed Text

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import jsonclass MachineStatus:

def __init__(self, label):

self.label = label

# The total number of beverages that were stocked last time we stocked the machine

self.totalStocked = 0

# The total number of beverages still left in the vending machine

self.inStock = 0

self.income = 0

def addBeverage(self, lastStock, inStock, price):

self.income += (lastStock - inStock) * price

self.totalStocked += lastStock

self.inStock += inStock

def getLabel(self):

return self.label

def sales(self):

return self.income

def pctSold(self):

return 100 * (self.totalStocked - self.inStock) / self.totalStocked

def __repr__( self ):

return '{} In Stock: {}, Stocked: {}, Sold: {}%'.format( self.label, self.inStock, self.totalStocked, round(self.pctSold(), 2) )

class InventoryItem:

def __init__( self, itemName ):

# The name of the beverage, we work under the assumption there will only be one InventoryItem

# for each named beverage

self.name = itemName

# The total number of this beverage item that were stocked last time we stocked the machines

self.totalStocked = 0

# The total number of this beverage item still left in the vending machines

self.totalInStock = 0

# The total number of slots that have this beverage

self.totalSlots = 0

def addToStocked( self, stockAmt ):

self.totalStocked = self.totalStocked + stockAmt

def addToInStock( self, inStockAmt ):

self.totalInStock = self.totalInStock + inStockAmt

def incrementSlots( self ):

self.totalSlots = self.totalSlots + 1

def getNumberSold( self ):

return self.totalStocked - self.totalInStock

def getSoldPct( self ):

return self.getNumberSold() / self.totalStocked

# We have an assumption here that the total number beverages that can be stocked

# in a slot is 8 beverages.

def getStockNeed( self ):

return 8 * self.totalSlots - self.totalInStock

def getName( self ):

return self.name

def getNumberInStock( self ):

return self.totalInStock

def __repr__( self ):

return '{} In Stock: {}, Stocked: {}, Slots: {}'.format( self.name, self.totalInStock, self.totalStocked, self.totalSlots )...

By purchasing this solution you'll be able to access the following files:

Solution.zip.