Compare two methods for equality
Hello,
I have a class named Sequence. In my program I would use a list of Sequence. One of the fields in this class and a list of objects of type Match. At one point in this program I have to compare all objects of type game with another list, which will allow me to complete their attribute. (The game attribute possess a position that is their position on the sequence by comparing this position with a list of known positions I just deduct it are the attributes of the match in question.) My question then is, who should have the method of comparison between the game and the other list? If you have solution for this problem, then please help me with this. Thanks in advance.
Re: Compare two methods for equality
Hello,
What do you comparing exactly? If the game is, simply redefine the class in the game equals method common to all objects. Otherwise I think you can also make a method in which Sequence compares two lists of matches, using the equals method of game that you've redefined. If you need more information on this, then you can visit the sun's official site and then you can see more detailed information on the same.
Re: Compare two methods for equality
Hello,
I am a little restricted by the choice of the JDK, to provide a method equals to each object. For me, it's always something external that can compare. So the answer to the question Who should have the method of comparison between the game and the other list? To be smarter, I noted that there is in the class Arrays methods for comparing lists.
Re: Compare two methods for equality
Hello,
There may be something somewhere that specifies the organization of these things, then it is he who will hold this as equals. Or do these rules come from constraints of your lists, or lists of objects, these bizarre rules do not fall from heaven. If they come from specific properties to these lists, then there must be method to the list. It is a difficulty responding to problems with compression algorithms that can explain compression algorithms, the objects themselves become algorithmic ideas, and we eventually get lost.
Re: Compare two methods for equality
Hello,
If I understand a game is a range of characters. By comparison "you mean that you are looking at whether a range of characters (game object) is included in another range of characters. Looking therefore to know whether an object matches "is included" in another object game. Who has the information necessary to answer this question? A prior, the game objects. Therefore, this responsibility must be assigned to objects game. I therefore see such a method "public boolean contains (Match m)" in the class matches.
Re: Compare two methods for equality
Hello,
But still the question of "who" will call contains and manage the assignment of attributes to the Games ... to me, it would rather blow to an external service (so in my opinion nor in the list or in game), but it's true it's a little too vague "functionally" to meet. I think this is the only solution for you, I can not think of an alternative right now, but if I come to knew about the same then I will post back.