Question

In: Computer Science

Write a class named RetailItem that holds data about an item in retail store.

Python 3

Your program will have 2 classes:

A) RetailItem Class

Write a class named RetailItem that holds data about an item in retail store.

Attributes: The class should store following data in attributes:

>item_Name

> Price

Methods:

> RetailItem class’s __init__ method should accept an argument for each attribute.

> RetailItem class should also have accessor and mutator methods for each attribute

B) MainMenu Class

Attributes: The class should store following data in attributes:

> List of RetailItem Objects: Inventory

Methods:

> createInventory(): method to create three RetailItem Objects store in list Inventory and populate following data in them

Item_Name

Price

Milk

10

Bread

20

Egg

15

> DisplayItems(): method to display items of Inventory List

>Method name main():  createInventory and display Inventory

Solutions

Expert Solution

Note: While copying the code from Chegg Windows, adds some extra characters and it disturbs the indentation as well. Please be cautious while copying. Please refer the screen shot of the code for indentation of the code.

Code:

===== RetailItem.py===

#retail item class

class RetailItem:

    #constructor to set name and price

    def __init__(self,item_name,price):

        self.item_name = item_name

        self.Price = price

    #accessors

    def get_item_name(self):

        return self.item_name

    def get_Price(self):

        return self.Price

    #mutators

    def set_item_name(self,name):

        self.item_name = name

    def set_Price(self, price):

        self.Price = price

=== MainMenu.py====

from RetailItem import RetailItem

#main menu class

class MainMenu:

    #declare a list of retail item for RetailItem

    Inventory =[]

    #createInventory method to create 3 objects of retail item and add it to list

    def createInventory(self):

        self.Inventory.append(RetailItem("Milk",10))

        self.Inventory.append(RetailItem("Bread",20))

        self.Inventory.append(RetailItem("Egg",15))

    #display all the items

    def DisplayItems(self):

        for item in self.Inventory:

            print("Item name :{}, Price: {}".format(item.get_item_name(),item.get_Price()))

    #main method to create inventory and display item

   def main(self):

        self.createInventory()

        self.DisplayItems()

#call main method

if __name__ == '__main__':

    mainDisplay = MainMenu()

    mainDisplay.main()

=============screen shot of code for indentation========

Output:


Related Solutions

a. Design a class named ItemForSale that holds data about items placed for sale on Carlos's...
a. Design a class named ItemForSale that holds data about items placed for sale on Carlos's List, a classified advertising website. Fields include an ad number, item description, asking price, and phone number. Include get and set methods for each field. Include a static method that displays the website's motto ("Sell Stuff Locally!"). Include two overloaded constructors as follows: A default constructor that sets the ad number to 101, the asking price to $1, and the item description and phone...
Create a class named UsedFurnitureItem to represent a used furniture item that the store sells. Private...
Create a class named UsedFurnitureItem to represent a used furniture item that the store sells. Private data members of a UsedFurnitureItem are: age (double) // age in years – default value for brandNewPrice (double) // the original price of the item when it was brand new description (string) // a string description of the item condition (char) // condition of the item could be A, B, or C. size (double) // the size of the item in cubic inches. weight...
Create a class Team to hold data about a college sports team. The Team class holds...
Create a class Team to hold data about a college sports team. The Team class holds data fields for college name (such as Hampton College), sport (such as Soccer), and team name (such as Tigers). Include a constructor that takes parameters for each field, and get methods that return the values of the fields. Also include a public final static String named MOTTO and initialize it to Sportsmanship! Save the class in Team.java. Create a UML class diagram as well....
Create a class Team to hold data about a college sports team. The Team class holds...
Create a class Team to hold data about a college sports team. The Team class holds data fields for college name (such as Hampton College), sport (such as Soccer), and team name (such as Tigers). Include a constructor that takes parameters for each field, and get methods that return the values of the fields. Also include a public final static String named MOTTO and initialize it to Sportsmanship! Save the class in Team.java. Write an application named TestTeam with the...
Create a class that holds data about a job applicant. Include a name, a phone number,...
Create a class that holds data about a job applicant. Include a name, a phone number, and four Boolean fields that represent whether the applicant is skilled in each of the following areas: word processing, spreadsheets, databases, and graphics: Include a constructor that accepts values for each of the fields. Also include a get method for each field. Create an application that instantiates several job applicant objects and pass each in turn to a Boolean method that determines whether each...
C++ Design a class named TermPaper that holds an author's name, the subject of the paper,...
C++ Design a class named TermPaper that holds an author's name, the subject of the paper, and an assigned letter grade. Include methods to set the values for each data field and display the values for each data field. Create the class diagram and write the pseudocode that defines the class. Pseudocode help please
Using C# Create a class named Inches To Feet. Its Main()method holds an integer variable named...
Using C# Create a class named Inches To Feet. Its Main()method holds an integer variable named inches to which you will assign a value. Create a method to which you pass inches. The method displays inches in feet and inches. For example, 67 inches is 5 feet 7 inches.
Create a class using C# named InchesToFeet. Its Main()method holds an integer variable named inches to...
Create a class using C# named InchesToFeet. Its Main()method holds an integer variable named inches to which you will assign a value. Create a method to which you pass inches. The method uses 2 ref parameters: feet, inches left of type int and a parameter that is not ref of type int to which you pass inchesinches. For example, 67 inches is 5 feet 7 inches.
Write a Data Element Class named Property that has fields tohold the property name, the...
Write a Data Element Class named Property that has fields to hold the property name, the city where the property is located, the rent amount, the owner's name, and the Plot to be occupied by the property, along with getters and setters to access and set these fields. Write a parameterized constructor (i.e., takes values for the fields as parameters) and a copy constructor (takes a Property object as the parameter). Follow the Javadoc file provided.Write a Data Element Class...
Write a class named Person with data attributes for a person’s first name, last name, and...
Write a class named Person with data attributes for a person’s first name, last name, and telephone number. Next, write a class named Customer that is a subclass of the Person class. The Customer class should have a data attribute for a customer number and a Boolean data attribute indicating whether the customer wishes to be on a calling list. Demonstrate an instance of the Customer class in a simple program. Using python
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT