Python Programming- Invoice Class Introduction: Requires creating classes and instantiating objects from created class Instructions: Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as data attributes--a part number (a string), a part description (a string), a quantity of the item being purchased (an int.) and a price per item (a Decimal). Your class shold have an __init__ method that intializes the four data ttributes. Provide a property for each data attribute. The quantity and price per item should each be non-negative--use validation in the properties for these data attributes to ensure that they remain valid. Provide a calculate_invoice method that returns the invoice amount (that is, multiplies the quantity by the price per item). Demonstrate class Invoice's capabilities. Once you have written the class, write a program that creates two Invoice Objects to hold the following data: ________________________________________________________________________________ Part Num Description Quantity Price Total ________________________________________________________________________________ 1001 Hammer 20 15 300 1002 locks 15 5 75 The program should store this data in the two objects, then display the object information in the manner shown in the table above , note that the total is NOT hardcoded, it’s calculated based on the item’s quantity and price. Note: Write program Pseudocode (detail algorithm) and add it as a comment block to the program.
Python
Introduction:
Requires creating classes and instantiating objects from created class
Instructions:
Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as data attributes--a part number (a string), a part description (a string), a quantity of the item being purchased (an int.) and a price per item (a Decimal). Your class shold have an __init__ method that intializes the four data ttributes. Provide a property for each data attribute. The quantity and price per item should each be non-negative--use validation in the properties for these data attributes to ensure that they remain valid. Provide a calculate_invoice method that returns the invoice amount (that is, multiplies the quantity by the price per item). Demonstrate class Invoice's capabilities.
- Once you have written the class, write a program that creates two Invoice Objects to hold the following data:
________________________________________________________________________________
Part Num Description Quantity Price Total
________________________________________________________________________________
1001 Hammer 20 15 300
1002 locks 15 5 75
- The program should store this data in the two objects, then display the object information in the manner shown in the table above , note that the total is NOT hardcoded, it’s calculated based on the item’s quantity and price.
Note: Write program Pseudocode (detail

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images









