.. (לתיקייה המכילה) | ||
In 2.1 - regarding the value: anInteger method - "if the digit value is not legal for the base it should be set to zero...", who is 'it'? (the base or the value ?) | |
The value |
If object of class BigInt holds 789 in base 10 and then the user changes the base to 5, the digits are not valid anymore. | |
No. You can assume this situation never happens (In other words: the base is set only once, before any of the digits are set) |
How can we write constructor with 2 parameters, something like : new base: aBase value:aValue ? | |
The new method cannot accept parameters. You should write a separate "regular" method that sets the fields of the object |
Should a method's code check that the parameters passed to the method are of the expected type (for instance, method value: anInteger will create a run-time error if anInteger's type is not an integer) ? | |
No. There is no need to do this check. |
How can a BigInt object hold several Digit objects? | |
You should use some kind of collection (List, Array, etc.). You can look at the code in tutorial 3B to see how to use the Set class, which is one of the collections of Little Smalltalk. Additionally, tutorial 3E throughly describes Little Smalltalk's collections. |
How do we treat a number which (temporarily) had some leading zeroes, but then a non-zero MSD was added to it? For instance, suppose the following binary digits are all MSD insertions: 1, 0, 0, 1. What String should be displayed: 1001[2] or 11[2] ? | |
1001[2] |
Section 2.2 requires that the BigInt class will use Digit objects. Yet, none of the methods of BigInt receives a Digit. Where should we use the Digit class/objects? | |
The fact that addMsd/addLsd accepts an integer parameter does not contradict the fact that BigInt uses Digit objects, INTERNALLY, to represent the number. |
Should the constructor of class Digit initialize the fields of the class to default values like: base <- 0, value <- 0 ? | |
Yes |
- My pringString method (in class BigInt) returns this string: "List (1 2 3) [5]" | |
No. The output should be exactly "123[5]". |