Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 2 - Constructors For the BitsByte class add the following constructors in addition to the default constructor above: Constructors: C + + BitsByte (

Task 2- Constructors
For the BitsByte class add the following constructors in addition to the default constructor above:
Constructors:
C++
BitsByte(int* ar)- Sets the data section with the value found in the array. Note: the array should be a size of 8 and should hold a binary representation of a whole number
BitsByte(int val)- Sets the data section to val
BitsByte(string val)- Sets the value of the data section to the value found in val. Note: val should be a string representation of a binary number.
Java
BitsByte(int val) Sets the bits correctly for the value being passed in. For instance, if you input 7 the bits should be 00000111 or stored as 11100000
BitsByte(int ar[]) Stores the values in the array to the appropriate bits. Please note that you need to make sure that each value of the array contains either a 1 or a 0. If it does not set all bits to 0
Task 2- Functionality
Add the following functions to your BitsByte class.
add
sub
mul
div
Each of these takes as an argument a primitive int variable and returns a complex type BitsByte that contains the answer.
Example Run:
C++
int main()
{
BitsByte bite(7);
BitsByte b1= bite.add(2);
cout << "Int: "<< b1.toInt()<< endl;
cout << "String: "<< b1.toString()<< endl;
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions