Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#Must be in C + + ( Data Structures / Algorithms ) and have no errors, I've got it partially done in Part 1 but
#Must be in CData StructuresAlgorithms and have no errors, I've got it partially done in Part but Im stumped, here's my code: beginning of main #include #include "BitsByte.h using namespace std; int main Byte bite; Test setValue function bite.setValue; Test at function for int i ; i ; i cout bite.ati endl; Test toInt and toString functions cout "Int: bite.toInt endl; cout "String: bite.toString endl; return ; main ends BitsByte.cpp begins #include "BitsByte.h Convert bits to integer int Byte::bitsToInt int value ; for int i ; i ; i value bitsi i; return value; Sets the value of bits void Byte::setValueint value for int i ; i ; i bitsivalue & ; value ; Function to get the bit at specific indexs int Byte::atint index return bitsindex; Converts bits to strings std::string Byte::toString std::string str; for int i ; i ; i Loop from index to str std::tostringbitsi; return str; Converts bits to integer int Byte::toInt return bitsToInt; BitsByte.cpp ends BitsByte.h begins #ifndef BYTEH #define BYTEH #include class Byte private: int bits; int bitsToInt; public: void setValueint value; int atint index; std::string toString; int toInt; Constructors ; #endif BitsByte.h ends
#Must be in CData StructuresAlgorithms and have no errors, I've got it partially done in Part but Im stumped, here's my code:
beginning of main
#include
#include "BitsByte.h
using namespace std;
int main
Byte bite;
Test setValue function
bite.setValue;
Test at function
for int i ; i ; i
cout bite.ati endl;
Test toInt and toString functions
cout "Int: bite.toInt endl;
cout "String: bite.toString endl;
return ;
main ends
BitsByte.cpp begins
#include "BitsByte.h
Convert bits to integer
int Byte::bitsToInt
int value ;
for int i ; i ; i
value bitsi i;
return value;
Sets the value of bits
void Byte::setValueint value
for int i ; i ; i
bitsivalue & ;
value ;
Function to get the bit at specific indexs
int Byte::atint index
return bitsindex;
Converts bits to strings
std::string Byte::toString
std::string str;
for int i ; i ; i Loop from index to
str std::tostringbitsi;
return str;
Converts bits to integer
int Byte::toInt
return bitsToInt;
BitsByte.cpp ends
BitsByte.h begins
#ifndef BYTEH
#define BYTEH
#include
class Byte
private:
int bits;
int bitsToInt;
public:
void setValueint value;
int atint index;
std::string toString;
int toInt;
Constructors
;
#endif
BitsByte.h ends
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