Question: I'm having errors with my cpp files. I was implementing everything in the hpp files but that seems incorrect to do. This is the lab

I'm having errors with my cpp files. I was implementing everything in the hpp files but that seems incorrect to do. This is the lab work that I was asked to do:

C++ Creating Classes (Invoice Class): Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four data membersa part number (type string), a part description (type string), a quantity of the item being purchased (type int) and a price per item (type int). Your class should have a constructor that initializes the four data members. Provide a set and a get function for each data member. In addition, provide a member function named getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as an int value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to 0. Write a test program that demonstrates class Invoices capabilities. Use classes, functions, objects, and exceptions to create an invoicing system.

Demonstrate understanding of three things: 1) Classes and functions 2) Objects 3) Exceptions.

I'm having errors with my cpp files. I was implementing everything inthe hpp files but that seems incorrect to do. This is thelab work that I was asked to do: C++ Creating Classes (InvoiceClass): Create a class called Invoice that a hardware store might useto represent an invoice for an item sold at the store. AnInvoice should include four data membersa part number (type string), a part

G lab2ExceptionHandeling.cpp Invoice.cpp Invoice.hpp Negative.cpp Negative.hpp 3 2e Negative.hppl 7 8 #ifndef NEGATIVE. HPP . 9 #define NEGATIVE-HPP- 10 #include iostream> 11 #include ioma nip 12 using namespace std; 13 14 class Negative public exception 15 private: 16 public: 17 Negative(){ 18 19 virtual const char* what() const throw(){ 20 return "Quantity cannot be a negative number, setting quantity to e"; 21 22 myex; 23 24 #endif /* NEGATIVE. HPP-*/ 25 26 Run d lab2ExceptionHandeling.cpp C Invoice.cpp h invoice.npp Lc Negative.cpp n Negative.npp e Invoice.cppl 7 8 #include "Invoice.hpp" 310 Invoice:: Invoice(string partNumber string description,int quantity double price) this->partNumber-partNumber; this->description-description; this->price-price; setQuantity (quantity); 12 13 14 215 16 17 18 // TODO Auto-generated constructor stub 19 Invoice:: Invoice() /I TODO Auto-generated destructor stub 220 21 23 24 c Negative.cpp in Negative.npp lab2ExceptionHandeling.cpp C Invoice.cpp 2/Name invoice.npp : lab2txceptionHandeling. cpp 9 #include iostream 10 using namespace std; 11 #include "Invoice.hpp" 12 #include "Negative . hpp" 13 14 int main) 15 string partNumber; 16 string description; 17 int quantity; 18 double price; 19 20 cout>partNumber; 23 cout>description; 25 26 cout>quantity; 28 29 cout>price; 31 32 Invoice i(partNumber,description,quantity,price); 34 cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!