Monday, December 12, 2011

Need Help base class number that holds a single integer value?

Write a base class number that holds a single integer value and contains one member function, print_it. Define three derived classes to print the value in hex, octal, and decimal..|||First create an abstract class like:





public abstract class Number {





//default Constructor


public Number() { }





public abstract print_it()





}





Then create the implementing classes like:





public HexNumbers extends Numbers {





//default Constructor


public HexNumbers() { }





public void print_it() {


/* enter code to print a hex number */


}





}





Then of course, you need to write a program that's using the classes.

No comments:

Post a Comment