Help decimalHexOctalBinary

Thread Starter

Hk3008

Joined Apr 26, 2012
1
I am being asked this
"Write a class called decimalHexOctalBinary that has four properties mainly decimalUnsignedInt (base 10), hexadecimalUnsignedInt ( base 16), octal UnsignedInt (base 8), and binaryUnsigned Int (base 2). Use gets and sets such that if anyone changes any of these four properties, the other three are altered to have corresponding values. You will need a number of additional private methods (e.g., functions) to implement this class.

Place code within main() to demonstrate that the class works correctly.

Include the UML notion appropriate for this class."

this is what I have ..... I am lost and do not know where to go from here I really dont even know this much but I had a book help me and it wasnt very informative either am I going in the right direction and if so where to go from here?
Rich (BB code):
#include <iostream>
using namespace std;
class HexOctBinClass
{
public:
	//
	// default constructor
	HexOctBinClass() 	{
		n = 0;
	}
	//
	// overloaded constructor that sets n
	//note parameter needs different name
	HexOctBinClass(int nn) {
		setN(nn);
	}
	//
	// used to set the value of N. Only positive Ns are allowed.
	void setN(int nn)	{
		if(nn <0) nn = nn *-1; 
		n = nn;
	}
	// returns the value of N.
	int getN() {
		return n;
	}
	// displays the value of N as Hex.
	void printHexN() {
		cout << "Hex N is: " << hex << n << endl;
	}
	private:
	int n;  // class level variable
};
int main() 
{
	HexOctBinClass foo(10);

	foo.printHexN();
	cout << "Dec N is: " << dec << foo.getN() << endl;
	return 0;
}
 
Top