/* main *****************************************************/
main()
{
// Create a multiple count object in base 10 with four digits
Multiple_Count first(10,4);
// Create a multiple count object in base 2 with 8 digits,
// initialized to 15.
Multiple_Count second(2,8,15);
int i;
cout << endl << "MULTIPLE DIGIT COUNTER DEMO" << endl;
cout << endl << "First value " << first.value() << endl;
cout << endl << "Second value " << second.value() << endl;
first.setvalue(5); // Load 5 into first
for (i=0; i < 123 ; i++)
first.increment(); // Add in 123
cout << endl << "First value " << first.value() << endl;
cout << endl << "Second value " << second.value() << endl;
first.subtract(second); // Subtract second from first
cout << endl << "First - second " << first.value() << endl;
second.add(second);
cout << endl << "Second + second " << second.value() << endl;
}
/* Classes **************************************************/
template
class Count { // COPY FROM COAD & NICOLA
//...
};
class Integer_Count : public Count {
// COPY FROM COAD & NICOLA
//...
};
class Integer_Count_With_Base : public Integer_Count {
public:
// Constructors/destructors
Integer_Count_With_Base() { reset_value = 0; reset(); base = 10;
next = NULL; }
Integer_Count_With_Base(int new_value)
{ // CODE REMOVED FOR OUTLINE
}
Integer_Count_With_Base(int new_value, int new_base)
{ // CODE REMOVED FOR OUTLINE
}
~Integer_Count_With_Base() { }
// Implementors
void increment();
void decrement();
// Data members
int base;
Integer_Count_With_Base *next;
};
// Integer_Count_With_Base member functions
void Integer_Count_With_Base::increment()
{
// CODE REMOVED FOR OUTLINE
}
void Integer_Count_With_Base::decrement()
{
// CODE REMOVED FOR OUTLINE
}
class Multiple_Count {
public:
// Constructors/destructors
Multiple_Count(int baseNumber, int numberOfDigits);
Multiple_Count(int baseNumber, int numberOfDigits,
int initialValue);
// Implementors
void setvalue(int new_value);
char *value(void);
void increment(void) { digit[0].increment(); }
void decrement(void) { digit[0].decrement(); }
void add(Multiple_Count&);
void subtract(Multiple_Count&);
int valueBaseTen(void);
// Data members
Integer_Count_With_Base *digit;
int base;
int number_of_digits;
};
Multiple_Count::Multiple_Count(int baseNumber, int numberOfDigits,
int initialValue)
{
// CODE REMOVED FOR OUTLINE
}
Multiple_Count::Multiple_Count(int baseNumber, int numberOfDigits)
{
// CODE REMOVED FOR OUTLINE
}
void
Multiple_Count::setvalue(int value)
{
// CODE REMOVED FOR OUTLINE
}
char *
Multiple_Count::value(void)
{
// CODE REMOVED FOR OUTLINE
}
int
Multiple_Count::valueBaseTen(void)
{
// CODE REMOVED FOR OUTLINE
}
void
Multiple_Count::add(Multiple_Count& aMultiple_Count)
{
// CODE REMOVED FOR OUTLINE
}
void
Multiple_Count::subtract(Multiple_Count& aMultiple_Count)
{
// CODE REMOVED FOR OUTLINE
}
}
// Integer_Count member functions
void Integer_Count::increment()
{
value++;
}
void Integer_Count::decrement()
{
value--;
}