Question: Submit your BigInteger class files ( BigInteger . cpp and BigInteger.h ) and a screen shot of your class in action using the provided demo

Submit your BigInteger class files (BigInteger.cpp and BigInteger.h) and a screen shot of your class in action using the provided demo code. Do not alter the demo code in any way; I will be running your classes in my own copy anyway. The code must run to completion if you are to recieve any credit. If the demo code crashes, you get a zero.
If your class supports only addition, the maximum grade is 50%.
Addition and all six relational operators is worth 60%(D).
Pass the multiplication test to reach a grade of 70%(C).
Now we do some subtraction to try to get you to 80%(B).
For full credit, your class must support all five integer operations.
Note that once you have division, mod is basically free.
This means that if you don't implement some of the operations, your code must throw exceptions instead, so that the test program exits with at least some grace. Exiting with an exception is not considered a crash.
#include
#include
using namespace std;
class myException: public exception
{
private:
string s;
public:
virtual const char* what() const throw()// how you override the base class virtual method "what"
{
return s.c_str();
}
myException() : exception(){ s = "Default Message"; }// default constructor
myException(const string & Message) : exception(Message.c_str()){ s = Message; }// a custom constructor
};
int main(){
// using the built in exception classes
int n;
while(true){
try{
cout "Enter an integer (zero to exit). If it's less than zero an exception will be thrown." endl;
cin >> n;
if (n ==0){
break;
}
if (n 0){
logic_error le("Value less than zero!");
throw le;
}
else{
cout "You gave me " n endl;
}
}
catch(const logic_error & le){// always catch objects by const reference, not value
cout "I just caught an exception!" endl;
cout le.what() endl;
}
}
cout "Thank you for playing Exception Demo Phase One!" endl;
// you can throw (and catch) anything you want
while(true){
try{
cout "Enter an integer (zero to exit). If it's even an exception will be thrown." endl;
cin >> n;
if (n ==0){
break;
}
if (n %2==0){
throw n;
}
else{
cout "You gave me " n endl;
}
}
catch(int ne){// catching a value
cout "I just caught " ne " as an exception!" endl;
}
}
cout "Thank you for playing Exception Demo Phase Two!" endl;
// let's throw a reference to an int and change it
while(true){
bool exception_happened = false;
try{
cout "Enter an integer (zero to exit). If it's even an exception will be thrown and one will be added to the integer." endl;
cin >> n;
if (n ==0){
break;
}
if (n %2==0){
throw &n;
}
else{
cout "You gave me " n endl;
}
}
catch(int * ne){// catching a pointer to an int, deliberately not const as we're going to change it
cout "I just caught "*ne " as an exception!" endl;
++*ne; // this updates the value stored at the pointer ne
exception_happened = true;
}
if (exception_happened){
exception_happened = false;
cout "There was an exception, the value is now " n endl;
}
}
cout "Thank you for playing Exception Demo Phase Three!" endl;
// using our custom exception class, default throw
while(true){
bool exception_happened = false;
try{
cout "Enter an integer (zero to exit). If it's even a custom exception will be thrown." endl;
cin >> n;
if (n ==0){
break;
}
if (n %2==0){
throw myException();
// throw myException("Oh No!");
}
else{
cout "You gave me " n endl;
}
}
catch(const myException & me){
cout "The exception was " me.what() endl;
}
}
cout "Thank you for playing Exception Demo Phase Four!" endl;
return EXIT_SUCCESS;
}
 Submit your BigInteger class files (BigInteger.cpp and BigInteger.h) and a screen

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!