Question: #include #include using namespace std; class Invoice { private: string a; string b; int c; int d; public: Invoice ( string pA , string pB

#include
#include
using namespace std;
class Invoice {
private:
string a;
string b;
int c;
int d;
public:
Invoice(string pA, string pB, int pC, int pD){
a = pA;
b = pB;
setC(pC);
setD(pD);
}
void setA(string pA){
a = pA;
}
void setB(string pB){
b = pB;
}
void setC(int pC){
if (pC <0){
c =0;
} else {
c = pC;
}
}
void setD(int pD){
if (pD <0){
d =0;
} else {
d = pD;
}
}
string getA() const {
return a;
}
string getB() const {
return b;
}
int getC() const {
return c;
}
int getD() const {
return d;
}
int getInvoiceAmount() const {
return c * d;
}
//The Copy constructor
Invoice(const Invoice& other){
a = other.a;
b = other.b;
c = other.c;
d = other.d;
}
// The Destructor
~Invoice(){
cout << "Invoice for "<< a <<" is being destroyed." << endl;
}
// The Clone method
Invoice clone() const {
return Invoice(*this);
}
//The Overloaded clone method with reference
Invoice clone(const Invoice& other) const {
return Invoice(other);
}
};
use the above code, add:
Task 1.6 write a test program to demonstrates class Invoices capabilities defined in
Task 1.21.5. The test program should follow the unit testing structure introduced at the lecture demos. (A reference example is on the Summary and reference web page on Moodle.)(10 points)
The main() function should follow the assertion format to print out pass or fail for each unit test. For example
// unit testing
std:: string message = testArrayAccess()? "passes!": "fails!";
//assertion form for calling the unit testing function;
std:: cout << "The case for array access "< message < std::endl
Finally, it should print out a statistics as m / n pass and k / n fail given the runtime unit test output, where m is the number of pass cases and k is the number of fail cases, and n is the number of total unit testing cases.
For example, if 5 total number of test cases are invoked in the main() and 5 cases pass. The program should print out 5/5 pass and 0/5 fail.

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 Programming Questions!