Question
Write the code in C++.Kindly use the given details Implementation of Integer Class Your goal is to implement Integer class. You will need to write
Write the code in C++.Kindly use the given details
Implementation of Integer Class Your goal is to implement Integer" class. You will need to write three files (Integer.h, Integer.cpp and Q4.cpp). Your implemented class must fully provide the definitions of following class (interface) functions. Please also write down the test code to drive your class implementation.
class Integer{ // think about the private data members... public: //include all the necessary checks before performing the operations in the functions Integer();// a default constructor Integer(int);// a parametrized constructor Integer(String); // a parametrized constructor void set(int);//set value int get()const;//get value at (i,j) int bitCount(); //Returns the number of one-bits in the 2's complement binary int compareTo(Integer); //Compares two Integer objects numerically. double doubleValue(); //Returns the value of this Integer as a double. float floatValue(); //Returns the value of this Integer as a float. Integer plus(const Integer&); //adds two Integers and return the result Integer minus(const Integer&); // subtracts two Integers and return the result Integer multiple(const Integer&); //multiplies two Integers and return the result Integer divide(const Integer&); //divides two Integers and return the result static int numberOfLeadingZeros(int i); /*Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified int value.*/ static int numberOfTrailingZeros(int i); /*Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specified int value.*/ static String toBinaryString(int i); //Returns string representation of i static String toHexString(int i); //Returns string representation of i in base16 static String toOctString(int i); //Returns string representation of i in base 8 };
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