.. (לתיקייה המכילה) | ||
What should be the type of the arguments for the methods in the assignment? | |
It is up to you to decide. Any reasonable decision is OK, but obviously there are better choices than others! |
can we assume correct input I.e. not test every method's input etc.? | |
Yes, unless otherwise specified in the assignment |
Do we have to have all our methods' arguments names begin with an 'a'? | |
This is the convention, please use it as well. |
When we are asked to return something in some method, do we have to print it to the standard output? | |
Unless there is a specific requirement in the method's description, you shouldn't. Return the information, and let the caller decide what (s)he would like to do with it. |
Shouldn't the method "printString" be "print"? | |
No. printString is supposed to return the information in a String form. We will learn later that this is the right method to override (both printString and print are defined in Object) and not print. CandidatesDB is an exception, since there is no good way to output the information as a String, so you override the print method. |
What is the difference between = and == in LST? | |
the operator = tests for equality of states, while == tests for equality of identities. For instance: if you do > s1 <- 'hello'<br> > s2 <- 'hello' then s1 = s2 will return true, while s1 == s2 will return false. We will talk about this in class. |
What should be the first argument for the method add: aCandidate for: aParty of: anAge? | |
This should be the candidate's name as a string (and not a Candidate object as some of you thought). I changed it in the assignment to make it more clear. |
In getCandidate: aCandidateName and getCandidateFor: aParty by "details" you mean that we should return a Candidate object? | |
It is up to you to decide. Take the most reasonable decision and go for it. |
Can a party have more than one candidate? | |
No. |
Can we assume that a candidates details will not change? For instance - can a candidate change a party? | |
You may assume that the candidate's details will remain constant after initialization (using the add: aCandidateName for: aParty of: anAge) |
Modifying print or printString causes for a change in the way LST prints information about the object; e.g., when modifying Candidate's printString, instead of printing just "Candidate" after a Candidate object is returned the modified printString method is used. Is that OK? | |
Not only that this is perfectly OK, this is also the desired behavior. As we will see later, LST really uses the object's class' print for printing these messages. |
Can a candidate represent more than one party? | |
No. |
Do we have to add a new method for every class we write? | |
Class' fields that are not specifically initialized will contain nil. So: if you have something better than nil for initializing your class' fields then you should define new; otherwise - you don't have to. |
In our program we use Set for our database and not Dictionary as suggested in the Exercise. Does that make any difference? | |
The type of the collection you use is up to you. We've had something in mind, but it is absolutely possible that other correct alternatives are available. Consider the properties of each collection, and decide which is most appropriate to your implementation. We do not have monopoly on correctness of design; it happened before that students came up with better solution than the one we've had in mind, so don't be afraid to choose something else than the one "implied" by us. As long it is correct, we will accept it (and you might even get some bonus if your choice improves ours!) |
In the "getCandidateFor", when the argument is a non-existing party, should we return nil, or let LST print it's error stack? | |
It is up to you. As long as your decision is reasonable, it is fine with us. In that case - both alternatives look reasonable to me. |
Can there be 2 candidates with the same name? | |
You may assume that each candidate has a unique name. |