Your HexaicosadecimalNumber class should know how to express a number
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Your HexaicosadecimalNumber class should know how to express a number

Part II: Add your attributes and methods

Your HexaicosadecimalNumber class should know how to express a number in both hexaicosadecimal and decimal. To do this, it should have two attributes: string Representation and double Representation. (What types should these variables be, and what should their access modifiers be?) 

Your HexaicosadecimalNumber class should have two constructors, both of which will populate the two attributes appropriately. One will take as input a String (representing a number in hexaicosadecimal), and the other will take as input a double. Both methods have to populate both attributes. 

You might now be thinking, "How do I populate both attributes when I only have one representation as input to the constructor?" You will need two helper functions: hexaicosadecimalStringToDouble(String in) and doubleToHexaicosadecimalString(double in). You should call these functions in your constructors as needed. 

You should also override the toString() method of HexaicosadecimalNumber. This is a special method that belongs to Java's Object() class, from which all other classes - including 

HexaicosadecimalNumber -are derived. The signature of the toString() method is 

public String toString() 

As you can see from the method signature, this function is public, takes no arguments, and returns a String. This function is called automatically when an object of that class is printed, for example by System.out.println(). The string should be in the following format: 

stringRepresentation (double Representation) 

That is, if your hexaicosadecimal number object is named temp and contains the value abcde (for which the equivalent decimal representation is 19010.0; check this later!), the result of 

calling 

System.out.println(temp) 

should be 

abcde (19010.0) 

For the two "helper” functions - hexaicosadecimalStringToDouble(String in) and double To HexaicosadecimalString(double in) - just have them return "dummy" values for now. (I.e. return 0.0 from the first function, and "NOT IMPLEMENTED" from the second.) At this point, you should have a complete working program (that doesn't do much). Compile and run your program. If you encounter errors, fix them before continuing.

Hint
ComputerObject-oriented programming (OOP): It is a computer programming model which basically organizes the software design around the data, or objects, rather than the functions and logic. An object could also be defined as the data field which do have the unique attributes along with the behavior. It also focuses on the objects which developers want to manipulate instead of the logic that is req...

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.