QuestionQuestion

Write a Python program with a class for managing the inventory of fruit vendor who sells only one kind of fruit. The vendor has three operations:

Add fruits to inventory – adds the number of fruits to the inventory
Sell fruits – reduces the number of fruits in the inventory
Check inventory – returns the number of fruits in the inventory

The program starts with zero inventory and supports the above operations.

Support the following menu for the vendor operations:
1 check inventory
2 add to inventory
3 sell fruits
4 exit the program

Solution PreviewSolution 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.

'''
Write a Python program with a class for managing the inventory of
fruit vendor who sells only one kind of fruit. The vendor has three operations:
'''


class Vendor:

    def __init__(self):
       """
            The program starts with zero inventory and supports the above operations.
       """
       self.fruit = 0
       pass

    def add(self, number):
       """
       Add fruits to inventory – adds the number of fruits to the inventory
       :param number: number of fruits
       :return: True if the number of fruits is positive
       """
       # only accept positive number
       if number >= 0:
            self.fruit += number
            return True
            pass
       return False
       pass

    """
         
          """
    def sell(self, number):
       """
       Sell fruits – reduces the number of fruits in the inventory
       :param number: number of fruit to be sold
       :return: True if these fruits could be sold
       """
       if number <= self.fruit:
            self.fruit -= number
            return True
            pass
       return False
       pass

    def check(self):
       """
            Check inventory – returns the number of fruits in the inventory
       :return: the number of fruits in the inventory
       """
       return self.fruit
       pass

    pass


selection = 0
vendor = Vendor()
while selection != '4':...

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

$10.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats