View the step-by-step solution to:

I have a question in pyhton : class named RetailItem that holds data about an item in a retail store.

I have a question in pyhton :


1. class named RetailItem that holds data about an item in a retail store. The class should have an __init__ method that accepts the retail store's item description, units in inventory, and price as arguments. All the data attributes must be private, which means, they are available to only code inside the class


2. Write 3 statements that create three instances of RetailItem class (in question 1).  The three instances should hold the data below.


       Description             Units in Inventory             Price

         Jacket                           12                          59.95

         Designer Jeans               40                          34.95

         Shirt                             20                           24.95


3.class named PersonalData that holds data about an employee. The class should have an __init__ method that accepts the employee's ID number, name, and address as arguments. Write appropriate accessor and mutator methods for the class.  All the data attributes must be private, which means, they are available to only code inside the class.


4.Write 3 statements that create three instances of the class PersonalData (in question 3). The three instances should hold the data below.


           ID number               Name                 Address

             1001                John Doe            100 Main Street

             2002                Jane Doe              200 Bell Drive

             3003                <Your name>         11928 Stonehollow Drive


5. class named Car that has the following data attributes:

  • __year_model (the car's year model)
  • __make (the make of the car)
  • __speed (the car's current speed)

The Car class should have an __init__ method that accept the car's year model and make as arguments. These values should be assigned to the object's __year_model and __make data attributes. It should also assign 0 to the __speed data attribute.

The class should also have the following methods:

  • accelerate - The accelerate method should add 5 to the speed data attribute each time it is called.
  • brake        - The brake method should subtract 5 from the speed data attribute each time it is called.
  • get_speed - The get_speed method should return the current speed.









-- Font family --

Andale Mono

Arial

Arial Black

Book Antiqua

Comic Sans MS

Courier New

Georgia

Helvetica

Impact

Symbol

Tahoma

Terminal

Times New Roman

Trebuchet MS

Verdana

Webdings

Wingdings

-- Font size --

1 (8pt)

2 (10pt)

3 (12pt)

4 (14pt)

5 (18pt)

6 (24pt)

7 (36pt)

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question