I'm wrong somewhere in my conversion with types, but not able to figure out. Please help me. I hope I have explained the problem well. If you need any more info, please ask me.
On line 49 you are passing two parameters to setDigit-the first is the value, and the second is the
index, but your setDigit function takes them in the opposite order.
As a matter of design, I would strongly encourage you to not force the user to manage the
"last used digit" in your internal array.
I checked the value coming in the digit variable and it is giving me correct output. But, when it is stored in the array and printed, only a blank line is coming.
Internally, your class works by storing the digits in an array. Externally, your user shouldn't need to be
aware of how you represent it. In fact, you even agree with that by virtue of making the array private.
But setLastDigit() sort of "exposes" knowledge of that internal array on the user. Not only do you
have to tell your user that internally you store the number as an "array" of bytes, but you also have
to tell them that you store the digits left justified in the array. For example, 1234 is represented as
"1234000000" and not "0000001234" (assuming MAX_DIGITS is 10 instead of 100 for brevity).
Oh -- but it gets worse, now that I look more closely. You store the digits backwards, so in
actuality, 1234 is stored as "4321000000" not as I said above. Again, in order to use setDigit()
as you've defined it, the user has to know also that you store the number backwards.
So in reality, although all your data members are private, the setDigit, getDigit, etc methods all
completely expose the internal implementation details of the class, so much so that you might
as well make the data members public because as it stands, you could hardly make any
significant changes to the class without breaking the code that uses it. (For example, you
could never right justify the number or store the digits in the right order).
Thanks for your comments, and I think I understood what you are saying. I'll modify my implementation and post new implementation tommorow . Could you please check it and give your comments, because I using this for learning purpose and your comments will be invaluable for me.