List all test cases that you believe are necessary to test the objects defined in Example 6.5.

Question:

List all test cases that you believe are necessary to test the objects defined in Example 6.5.


Data from Example 6.5

An Example of Testing Object-Oriented Programs
#include
class Complex
{
public:
double real;
double imag;
Complex(){ double real = 0.0; double imag = 0.0;}
double realpart (Complex z) { return z.real; }
double imagpart (Complex z) { return z.imag; }
void print(Complex z) {cout << z.real<< " + " << z.imag <<"i" << endl;}
};
Complex operator + (Complex a, Complex b)
{
Complex C;
C.real = a.real + b.real;
C.imag = a.imag + b.imag;
return C;
}
ostream &operator << (ostream & stream, Complex a)

{
cout << a.real << " + " << a.imag << "i" << endl;
return stream;
}
main()
{
Complex z1, z2;
float x1, x2,y1,y2;
cout << "Enter the real and imaginary parts of "
<< "the first complex number" << endl;
cin >> x1 >> y1;
cout << "Enter the real and imaginary parts of "
<< "the second complex number" << endl;
cin >> x2 >> y2;
z1.real = x1;
z1.imag = y1;
z2.real = x2;
z2.imag = y2;
z1.print();
z2.print();
cout << z1 << endl;
cout << z2 << endl;
z2 = z1 + z2;
cout << z2;
}

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: