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

  Write a program that asks the user to enter an integer

Write a program that asks the user to enter an integer between 1 and 15. If the number entered is outside that range, your program should print out.

  Write c code to repeatedly ask the user for a number

Write C code to repeatedly ask the user for a number, then once the user enters 0, the code displays the min, max and average of all values entered.

  Program on basic arithmetic operation

Two integers must be compared before the arithmetic operation and Subtract the two integers provided the first integer is greater than the second integer, otherwise add the two integers and subtract the second integer from the first integer.

  Calculate the volume by formula

Write program in C++ : - write a class VolumeOfBox that calculate the volume by this formula : length * breadth * height this class has three data member ,and the member function which calculates the volume and print the result by using pointer to..

  Program that is supposed to search message.txt and print out

I'm having trouble with a program that is supposed to search message.txt and print out the message. i will upload instructions. We must use functions, and we were not instructed on how to search char arrays for this purpose and I am lost. Your hel..

  Database for a programming support environment

Design the database for a programming support environment. In this environment programmers produce programs, which are written in given programming languages.

  Discuss about the class string tokenizer

Although we did not discuss it when we covered the class String Tokenizer, the class String Tokenizer has a method with the following heading.

  Value of x after the following code is executed

What will be the value of x after the following code is executed?int x = 20, y = 30;while (y

  Member function is like and unlike a regular function

Research and discuss the ways in which a C++ member function is like and unlike a regular function. (Fifty + W O R D S)

  Program that uses the attached data file as input

Please do this the easiest way possible, I am learning C++ by myself but I just don't understand input/output so this will help me understand it better.

  Program to print out the values and their counts

So we read in each number and add the number to an ordered linked list. If we are adding a number to the list and we find that number, then we will just count it. If we do not find the number in the linked list, then we will add a new node to the ..

  Write a program that has a function prototype

Write a program that has a function prototype before main and an implementation of the function after main.

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