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 program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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