NL Can is a local can-making company that makes cans using an eco-friendly material. Recently a number of new eco-friendly paint companies have started up in the area and they have been placing large orders for paint cans in which to put their eco-friendly paint. NL Can has asked you to design, implement and test a Python class, CanOrder, to generate order objects for cans with the following attributes (instance variables) and class variables

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

NL Can is a local can-making company that makes cans using an eco-friendly material. Recently a number of new eco-friendly paint companies have started up in the area and they have been placing large orders for paint cans in which to put their eco-friendly paint. NL Can has asked you to design, implement and test a Python class, CanOrder, to generate order objects for cans with the following attributes (instance variables) and class variables.

Class variables:

  • NoOfOrders is a class variable that keeps track of the number of orders created (initially 0); NoOfOrders automatically increments with each new object created, i.e., when the first object is created, NoOfOrders should become 1, when the second object is created, NoOfOrders should change to 2, etc.

  • NextOrderNoisaclassvariable,initializedto100,whichisusedtogeneratetheorderIDnumberfor each order as a sequence of even numbers, starting with 100; i.e., the first order would have an orderID of 100, the second order created would have an orderID of 102, etc.

    Instance variables:

  • orderID is a unique number identifying the can order and is set using the NextOrderNo class variable

  • quantityOrderedisthenumberofcansordered(defaultvalue0)

  • radiusistheradiusofthecanininches(defaultvalue0.0)

  • heightistheheightofthecanininches(defaultvalue0.0)

  • handleisaTrue/Falsevalueindicatingifthecansintheordershouldhaveahandle(True)ornot(False) (default value False)

    Also include the following methods:

  • a constructor method for the CanOrder class with default values for all 4 parameters (not including the self parameter)

  • three accessor methods, one to retrieve the ID of the order, one for the radius, and one for the height

  • two mutator methods, one to change the radius of the can, and one to change the height of the can

  • a method called getTotalSurfaceArea to compute and return the total surface area of all cans

    ordered; the formula for the surface area of a can is: 2πr 2 + 2πrh (note: use the math library to get the

    constant variable pi and the pow function)

  • a method called getTotalCost to compute and return the total cost of the order, where the cost of the

    material used is half of a cent ($0.005) per square centimetre of surface area and if handles are required,

    then an extra fifty cents ($0.50) is added for each can

  • the special __str__() method to print the information about the order including the orderID, the radius

    and the height of the can, the quantity ordered, the handle option (True/False), the total surface area of material used for the quantity of cans ordered, and the total cost of the order with appropriate descriptive labels, as shown in the sample output

    Also include a main function to test the defined class as follows:

  • create 2 CanOrder objects

  • print information about each order using the special __str__() method

  • change the height of the can in the second order and print the order ID, the updated height and the

    updated total cost of the order with appropriate descriptive labels

  • print the total number of orders with an appropriate descriptive label

• print the total cost of all the orders (both orders, including the effect of the changed height of the second order), with an appropriate descriptive label

Call the file containing your class and main function, nl_cans.py.

Sample input/output:

Order ID: 100 Can Radius: 5 cm Can Height: 10 cm Quantity Ordered: 100 cans Handle Needed? False Total Surface Area: 47123.89 sq.cm. Total Cost: $235.62 Order ID: 102 Can Radius: 7.5 cm Can Height: 20 cm Quantity Ordered: 300 cans Handle Needed? True Total Surface Area: 388772.09 sq.cm. Total Cost: $2093.86 The height of cans for Order ID 102 has been changed to 21.00. The new cost of for Order ID 102 is $2164.55. The total number of orders received was 2. The total cost of all orders received was $2400.17.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY