Define the four private variables of the item class

Assignment Help C/C++ Programming
Reference no: EM132277115

Assignment: Classes and Object - Inventory Item as Object

In this assignment the idea is to use an Item class to capture what you need for recording and displaying the details of an order from an online store like Amazon. This is a Class and Object assignment.

For the assignment you must define and implement the Item class so that the code shown immediately below can produce the result shown below that. You will need to define the four private variables of the Item class for the price, weightInOunces , description, and quantity.

You are to include a constructor (__init__), that takes three input parameters for the price, weightInOunces, and description, but not quantity which should be set to a default value of 1

You will also need to create the remaining methods that are used in the code below the gets and sets. The contents of the main function and the output are shown below. Copy, and do not change, the code below. Pay close attention to the values in the output. If you do not match the details correctly, some of your values will not be the same as those shown. (Hint: There's a reason that the getOrderPrice() method is not called getPrice() and in the example it affects the order for glasses.) Name your main file youOrderReceipt.py, e.g. AjoyOrderReceipt.py.

Part B: Create a second main file youOrderReceiptArray.py e.g. AjoyOrderReceiptArray.

Using an list of item objects, instead of item1, item2, etc. Put item1 item2, item3 and item4 in the list. For each item in the list call __str__() and Use the list and the for loop to find the dTotalPrice and iTotalWeight as in part A.

Turn in your zipped package folder with all the three .py source files(Item.py and the two main files). Having correct formatting will now be part of the grade.

def main():

dTotalPrice = 0.0

iTotalWeight = 0

# Put the 4 items being ordered in item1 through item 4

item1 = Item.Item(24.99, 14, "Wireless Mouse")

item2 = Item.Item(22.49, 27, "USB Keyboard")

item3 = Item.Item(24.99, 12, "HDMI Cable")

item4 = Item.Item(7.99, 7, "Reading Glasses")

item4.set_quantity(2);

# Show the details of the order using show()

print("Here are your shopping cart contents.")

print(item1);

print(item2);

print(item3);

print(item4);

# Compute the total price and total weight in this section

dTotalPrice += item1.getOrderPrice()

dTotalPrice += item2.getOrderPrice()

dTotalPrice += item3.getOrderPrice()

dTotalPrice += item4.getOrderPrice()

iTotalWeight += item1.getOrderWeightInOunces()

iTotalWeight += item2.getOrderWeightInOunces()

iTotalWeight += item3.getOrderWeightInOunces()

iTotalWeight += item4.getOrderWeightInOunces()

# Here we show the order details

print("The price of your order is tiny_mce_markerquot; + str(dTotalPrice));

print("The shipping weight is", (int)(iTotalWeight / 16),

"pounds", iTotalWeight % 16 , "ounces");

main()

The method __str__() should print out as shown below for each item.

$24.99 each for 1 Wireless Mouse.

$22.49 each for 1 USB Keyboard.

$24.99 each for 1 HDMI Cable.

$7.99 each for 2 Reading Glasses.

Reference no: EM132277115

Questions Cloud

What fraction of network bandwidth is filled with headers : In a network with an 8-layer architecture and protocol hierarchy, applications generate messages of length M bytes. Assuming each layer has a different header.
Write a description of the systems project : Your implementation was successful, and it's time to plan ahead for future projects. One important piece of project reflection and creating future proposals.
Quantitative research versus qualitative research in nature : What is the difference between a quantitative research versus a qualitative research in nature?
Advantages of hiring internal and external candidate : Describe the advantages and disadvantages of hiring an internal and external candidate.
Define the four private variables of the item class : For the assignment you must define and implement the Item class so that the code shown immediately below can produce the result shown below that.
Most important factors in positions for compensation : How do you identify the most important factors in positions for compensation?
Show the transition between states in the monitor : Include a main function that prints to stdout when the conditions for the monitor change (i.e. show the transition between states in the monitor.)
Summarize the method of patient recruitment : For this assignment - Summarize the experimental design and method of patient recruitment (according to the authors)
Email processing and 5s discussion : What parameters do you use to decide? Do you leave it in your inbox? Inventory your current in-box –

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create a program that verifies the strength of a password

Create a .cpp program that verifies the strength of a password that a user is entering is strong (complex/secure) enough. In the main area of the program, prompt the user to enter a password.

  Write an oop program to store integers into a linked list

Write an OOP program to store integers into a linked list. Add code so that the linked list sorted.

  Declare and define constructor

Declare and define constructors and Declare and define destructors - Describe what is an attribute or data member of a class

  Write a program with a while loop to print 1 to n in square

Write a program with a while loop to print 1 to N in square brackets. N is an integer input from the user. (i) Write the same program using a for-loop

  Analyze the time complexity and space complexity

Develop a simple prototype version of algorithm in C++. Specifically, you will build an in-place, order reversal algorithm - analyze the time complexity and space complexity of your algorithm

  Using songs.dat in our folder

Using songs.dat in our folder on the P: drive, construct a playlist of 10 random songs. Use a struct to hold the song data (name and time in seconds), and output the playlist (song name and time,

  Calculate the invoice for a client and then print out an inv

Prepare a program in java that can calculate the invoice for a client and then print out an invoice to the screen.

  Write a grade book program

Your English instructor, realizing you are a programmer, asks you to write a Grade Book program for his class to help him compute final grades

  What is the output of the program below

What is the output when the following code fragment is executed?

  Explain in a one to two 1-2 page narrative a use case

as an intern software developer for a retail bank you have been tasked with developing use cases to support the atm

  Create a graphical (not text-based) visual c++ program

Create a graphical (not text-based) Visual C++ program that allows the user to enter the coefficients for a system of four equations with four unknowns. Include a button that when clicked, will solve the system of equations and display the results in..

  Write algorithm to calculate total expences

Write algorithm to calculate total expences

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd