Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 BigIntegercpp 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
Addition and all six relational operators is worth D
Pass the multiplication test to reach a grade of C
Now we do some subtraction to try to get you to 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 scstr;
myException : exception s "Default Message"; default constructor
myExceptionconst string & Message : exceptionMessagecstr s Message; a custom constructor
;
int main
using the built in exception classes
int n;
whiletrue
try
cout "Enter an integer zero to exit If it's less than zero an exception will be thrown." endl;
cin n;
if n
break;
if n
logicerror leValue less than zero!";
throw le;
else
cout "You gave me n endl;
catchconst logicerror & le always catch objects by const reference, not value
cout "I just caught an exception!" endl;
cout lewhat endl;
cout "Thank you for playing Exception Demo Phase One!" endl;
you can throw and catch anything you want
whiletrue
try
cout "Enter an integer zero to exit If it's even an exception will be thrown." endl;
cin n;
if n
break;
if n
throw n;
else
cout "You gave me n endl;
catchint 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
whiletrue
bool exceptionhappened 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
break;
if n
throw &n;
else
cout "You gave me n endl;
catchint 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
exceptionhappened true;
if exceptionhappened
exceptionhappened 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
whiletrue
bool exceptionhappened false;
try
cout "Enter an integer zero to exit If it's even a custom exception will be thrown." endl;
cin n;
if n
break;
if n
throw myException;
throw myExceptionOh No;
else
cout "You gave me n endl;
catchconst myException & me
cout "The exception was mewhat endl;
cout "Thank you for playing Exception Demo Phase Four!" endl;
return EXITSUCCESS;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started