Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Find the transition matrix for Example 1.

Answered: 1 week ago

Question

=+52-3 Discuss the characteristics of emerging adulthood.

Answered: 1 week ago

Question

1.Which are projected Teaching aids in advance learning system?

Answered: 1 week ago