GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Create a class called Cart that is used to hold items while…

Create a class called Cart that is used to hold items while doing on-line shopping.  Cart is a subclass of the built-in list class.  Write the class definition code (i.e. the signature line and constructor method) needed to allow other code to create a Cart object that has two attributes: the shopper’s name (cust_name) and a cart number (cartNo).  cust_name is a string parameter while cartNo is an integer.  cartNo is created by the class code and is 1 for the first cart created, 2 for the second, etc.   Include a method called addItem() to add items to the cart.  addItem() has two positional parameters: (1) item – the name of some item (type string), and (2) quantity to be added (type integer).  For example item = ‘eggs’ and quantity = 2 adds two boxes of eggs to the cart.   addItem() ensures the item to be added is one of the 6 items in the inventory dictionary below and that the quantity is an integer.  However, it is possible that items will be added to the inventory at any time.  It returns False with a reason if not.  Otherwise, it adds the item to the cart list (‘self’), the quantity, and the extended price (quantity times the price taken from the inventory dictionary).  What is added is a list with 3 elements:  [, , ].  If the item () is already in the cart the method just adds the quantity to what’s already in the cart and updates the extended price.  The method uses the parent class’s append method to add to the cart and returns True and a message that items were added.  Example: if two boxes of eggs are added to a new Cart, that would appear this way in the cart: [ [‘eggs’, 2, 10.98] ].   If another box of eggs is added (parameters item = ‘eggs’ and quantity = 1) the item in the cart would be updated to [ [‘eggs’, 3, ‘16.97] ].  If two loaves of bread were added that cost 3.99 each, the cart (self) would be updated to  [ [‘eggs’, 3, 16.97] , [‘bread’, 2, 7.98] ]. The following inventory has all the items that might be added to the cart (it’s a small inventory).  Assume it’s part of your code as a class level attribute and do not retype it in your answer. inventory = {‘eggs’: 5.49, ‘milk’: 3.99, ‘fish’: 9.95, ‘beer’: 9.95, ‘rice’: 7.00, ‘bread’: 4.99}

Read Details

What is the probability that an arriving student will find a…

What is the probability that an arriving student will find at least two other students waiting outside Professor Nutty’s office? Please write the answer in decimal form. For instance, if the probability is 45%, write 0.45.

Read Details

In project management, if the scope of a project increases w…

In project management, if the scope of a project increases while time and resources remain fixed, which of the following is most likely?

Read Details

Calculate the throughput rate in applications per hour.

Calculate the throughput rate in applications per hour.

Read Details

Look at the recording window, and if you can not see your fa…

Look at the recording window, and if you can not see your face, hands, computer screen, keyboard, workspace (e.g. whiteboard, calculator)  at the same time without moving the camera or items, you need to adjust your camera angle so that you are able to see everything. DO NOT LIFT YOUR CALCULATOR AND WHITEBOARD DURING TEST.   Thank you for your help!

Read Details

What is the probability of a claim form being defective?  Pl…

What is the probability of a claim form being defective?  Please write the answer in decimal form. For instance, if the probability is 5%, write 0.05.

Read Details

What is the optimal number of pairs of shoes you should orde…

What is the optimal number of pairs of shoes you should order?

Read Details

Determine whether the lines are parallel, perpendicular, or…

Determine whether the lines are parallel, perpendicular, or neither.4x + 5y = 15x – 4y = 20

Read Details

What is your expected profit?

What is your expected profit?

Read Details

Find the slope and the y-intercept of the line.y = -2

Find the slope and the y-intercept of the line.y = -2

Read Details

Posts pagination

Newer posts 1 … 3 4 5 6 7 … 84,959 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top