1. Define a new C++class named “PurchaseOrder” that manages a purchase: number of items(integer), cost per item(double), and the description of the purchase(string). Please note that the total can be derived from multiplying the quantity with the cost per item and should not be a data member. The class must provide at least the following two methods: •toString methods that return the string containing all the information about the purchase order in the following format: Description() Quantity() Total() For example, here is a specific purchase order: Description(A box of candy) Quantity(100) CostPerItem($1.25) Total($125.00) •compareTotal method that compares the information between the 2 PurchaseOrderobjects and returns -1 if the total of the first purchase is less, 0 if they both have the same total, and 1 if greater. Please make use of the fact that there must be an object to call this method with. Note: you can add as many other methods as you need. Show how this class is being used and tested. 2. Write a function named “createPurchaseOrder” that accepts the quantity (integer), the cost per item(double), and the description(string). It will return a newly created PurchaseOrderobject holding that information if they are valid: quantity and cost per item cannot be negative and the description can not be empty or blank(s). When it is invalid, it will return NULL to indicate that it cannot create such PurchaseOrderobject.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

1. Define a new C++class named “PurchaseOrder” that manages a purchase: number of items(integer), cost per item(double), and the description of the purchase(string).

Please note that the total can be derived from multiplying the quantity with the cost per item and should not be a data member.

The class must provide at least the following two methods:

•toString methods that return the string containing all the information about the purchase order in the following format:

Description(<purchase-descripton>) Quantity(<number-of-items) Cost(<cost-per-item>) Total(<total-cost-of-this-purchase>)

For example, here is a specific purchase order: Description(A box of candy) Quantity(100) CostPerItem($1.25) Total($125.00)

•compareTotal method that compares the information between the 2 PurchaseOrderobjects and returns -1 if the total of the first purchase is less, 0 if they both have the same total, and 1 if greater. Please make use of the fact that there must be an object to call this method with.

Note: you can add as many other methods as you need. Show how this class is being used and tested.

2. Write a function named “createPurchaseOrder” that accepts the quantity (integer), the cost per item(double), and the description(string). It will return a newly created PurchaseOrderobject holding that information if they are valid: quantity and cost per item cannot be negative and the description can not be empty or blank(s). When it is invalid, it will return NULL to indicate that it cannot create such PurchaseOrderobject.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education