![]() |
.. (לתיקייה המכילה) | |
How does push effects an infinite stack? | |
If push is called on an infinite stack, then the pushed element (or elements) should appear before the original content. For example:
|
can we use array (which size is unknown during compilation) in push(int[]) and top(n)? | |
Yes, you may (actually you must). as an exception to the guidelines given in the assignment you can use arrays when implementing this functions. In int push(int[] n) you may use the array you receive as a parameter. you may not save a reference to it (or a copy of it) after the method terminates.In int[] top(n) you may create an array of size n in order to return an output.Aside from the above 2 exceptions you are not allowed to use arrays (which size is unknown during compilation) in your implementation. |
Can we use strings as a container in order to implement the assignment? | |
No, you should treat String, StringBuffer or any other Class of the kind (which has a variant size content) as a Collection. you may NOT use it. The limitation on arrays is not meant to give you a "hard time" trying to fine a workaround. you should find a solution that does not require the usage of this kind of containers. |
What should we do if | |
you should throw an IndexOutOfBoundsException .
|
Why is | |
In Java co-variance in return value is allowed. this means that if we have the following:
then the foo() in B Overrides the foo() in A.we will learn more about it during the course. this means that you may always define clone() to have a return value of the defining class's type.
|
Why an I getting the following error:<br/> | |
You are not working with Java 6. please make use you use the latest version of Java |
Can you please clarify what should be supported by equals? | |
OK:
|
Can 2 stack be equal even if they don't meet the conditions published above? | |
Yes. 2 stack may be equal if they have the "same content". If 2 stack meet the published conditions, then they must be equal. If 2 stack have different content then they must not be equal. anything between that is up to you (and will not be tested). "same content" means that any series of pops will return the same values. As to what to do with elements that cannot be reached (when concatenating a stack after an infinite stack) - this case will not be tested as well. |
Can ShifedNaturalStack receive a negative argument in the constructor? | |
Yes it can. So can BoundedNaturalStack (as long as the first parameter is smaller than the second one). |