.. (לתיקייה המכילה) | ||
The method numVoted: aCandidate is called numVotes: in NationalBallotBox class. Is it a bug? | |
Yes, it should be called numVoted: as well. This was fixed in version 1.01. |
What is the definition of a legal candidate in LocalBallotBox' voter:aVoter for Candidate:aCandidate? | |
Any candidate registered in the candidates DB. |
Can we assume that a voter cannot be removed after (s)he voted? | |
Yes. |
Can voters that belongs to different local ballot boxes have the same name? or the name of each voter is unique for the entire system? | |
The names are unique per local ballot box, but not necessarily unique for the entire system. |
in class votersDB what hapens in method didVote if the voter does not exist - is it o.k. to print an error message or should it return false | |
The behavior is up to you: if you think this is an error then treat it as such (by calling smalltalk's error: method). Otherwise - do what you think is appropriate. Regarding returning flase - think about this in respect to the caller's expectatios of the returned value from this method. |
How can StateBallotBox return correct electors number when we can't set its name or its electors number? | |
Who said you can't? the interface given to you does not contain all methods you'll need to implement. You will have to add some of your own methods. |
Should the local ballot box print all the candidates votes statistics? | |
You mean in printString? well, not all of it. Printing the participation is enough. |
In VotersDB - What is the participation if there are no voters registered in the DB? | |
0% is OK. |
In the classes StateBallotBox and NationalBallotBox should we support a method for voters to vote in the elections (Which will somehow direct the voter to his respective LocalBallotBox using data of the vote (Like state and region))? | |
This is an interesting design question and pretty much depends on how you want your system to be built. Personally, I think this is beyond the scope of the national and state ballot boxes roles. As I see it, their role is to gather results from ballot boxes that are "lower" in the hierarchy, and leave the role of actually handling the voting process to the local ballot boxes. |
Can we submit the assignments on CD or via e-mail? | |
No... I need to put remarks on your files (that's why not a CD) and I did not automate the process of returning the assignments to you via e-mail just yet (that's why not through e-mail...) |
Is it considred an oop design error chosing not to use inheritance in cases inheritance gives us only common interface when we must implement the nethods seperately? | |
You should make a common parent class only if there is a real meaning for the abstraction. For instance: both a classes that represent a bycicle and a fish might have a method named "weight"; in the general case, however, this is obviously not a good enough reason for making a common interface class with the definition of this specific method for both! As a rule of thumb I'd say that a common parent class is required when: - both classes share a large enough amount of code (AKA implementation inheritance for prevention of code duplication) - you want both classes to be polymorphic, namely there are places in the code where objects of both classes can be manipulated (AKA interface inheritance). There is no value for defining a common interface just for the sake of having a common interface. Regarding the local/state/national ballot box - it depends. Would you like these classes to be polymorphic? as you wrote, there's almost no code that they can share so this is the only reason left. If you do - then create a common parent class; otherwise - don't. |
Is it considered as good OOP manner to use an inherited field from the father within the son? | |
Let me divide the answer into two parts: First, it is perfectly OK to use the field from the mother in the daughter class. This is exactly what "protected" member functions and variables are in C++! in the process of abstraction there might be some functions or variables that are common to the entire tree of classes, but that we do not want to share with the rest of the world; so this is OK.Second, as a good software engineering manner, it is best to update each member variable via one function that performs all necessary checkups whenever possible. By doing this you both ensure that the variable is checked each time it is being modified (and you know exactly where), and make it easier to change the field in the future (only one function really depends on it!) So - the best composition is of a variable (that might be private in that case!) and a modifying method (that should be protected). In LST, where you don't have the choice of private/protected, you just add the member variable and a member modifying method to the same class. |
How are we suppose to access the local ballot boxes if they are created inside StateBallotBox? | |
You can do one of the following, or both: - Make StateBallotBox' |addBallotBox: aRegion withVoters: aVotersDB" return a reference to the newly created LocalBallotBox and keep this reference for testing - Create another method that returns a reference to a region's LocalBallotBox by its name There might be other ideas as well. |
In the description of printString of the VotersDB class it says that it should PRINT general information about the database. Shouldn't printString return a String? | |
Right. The data should be returned as an object of type String. I'll fix that. |
We think that a common parent class for StateBallotBox and NationalBallotBox can save a little code reuse, but we can't see what other benefit we might gain from it; do we have to create such class just to save code reuse? | |
Code reuse is not the only concern you have. If such class will make your design awkward and your code less readable, then this might not be such a good idea to do all this just for saving some code reuse. Use your judgement and decide. |
Did someone find the major error mentioned in assignment? | |
I did not plant a major error deliberately!!! All I wanted is that you help me to find such error if there is one :-) |
What's new in version 1.03? | |
- Incorrect internal links were fixed - Description of the electronic submission added - Some more description regarding the creation of StateBallotBoxes (3rd item in the Notes subsection) added - A typo in item 1 of the Notes list was fixed. |
Is it a good idea to hard-code the names of the states in NationalBallotBox? on the one hand, this number list not expected to change; on the other - it is ugly. | |
This is ugly. I've allowed this just to make your life easier, but a better alternative is to use some file for keeping the state+number of electors. Although the list of states is not expected to change anytime in the near future, the number of electors per state do change from time to time, so it is definetely better not to hard-code it. |
Should the number of electors per state be calculated, or can it be assumed that they are known a-priori? | |
You may assume that they are know. As written in the assignment, just pick some number you like and use it. |
Should I support the option of more than one winner? | |
No. Also, you may assume that a single candidate gets the majority of vote/electors in the elections (no need to worry about a tie). |
What should printString do in StateBallotBox and in NationalBallotBox? | |
Participation in the elections and the name of the winner are enough. You are welcome to add more information if you like. |
Should I check for argument types? | |
No. |
Can we assume that first we create all the region and state boxes (as part of national), and only after that we start adding candidates to the structure? | |
No. Candidates can be added also after creating the ballot boxes. |
In the third bullet in the notes it is written that "it is even better to get them (with the number of electors) from a file" (where "them" refers to the StateBallotBoxes). Do u mean it is ok to make a addStateBallotBox method and call it just after the creation of nationalBallotBox, from a test file (and not making the constructor read from the file)? | |
I meant that the best thing is that the constructor will read them from a file. If you choose not to initialize the StateBallotBoxes in NationalBallotBox' constructor, then some other solution must be found, obviously. A possible solution is to initialize these ballot boxes from a test file. |