I recall this attitude from professors in beginning classes. They forget that it really isn't that easy when you're starting and focus on one small piece of the design which they feel is 90% of the effort -- making a single decision about the structure of a class!i honestly dont know if its supposed to hold a string and its list, i asked my lecturer and he said i cant tell u this then i'll be doing most of the work for u!!!
Perhaps name one house "parent" and the other "child" so the caller knows which is which. Also, I'm unclear what the second method does. The comment makes it sound like they're the same method. Does the second one add multiple houses to house2? Or is the ArrayList house1's list of children?public boolean addToHouse(House house1, House house2);
public boolean addToHouse(ArrayList house1, House house2);
A single class will usually have multiple methods that make up one or a few coarse responsibilities. Especially in the beginning, don't over-emphasize cohesion (few responsibilities) or you end up with a whole bunch of entangled classes that are harder to understand than one or two larger classes.Originally posted by H Melua:
making the House creates the children, and the houselist makes them parents and adds some of those children to the parents created, and that is making houselist in charge of 2 major functions!!
This is the reason you must override equals(Object) in the House class. The House "this" is equal to the passed in Object only ifOriginally posted by H Melua:
when i do find(), wouldnt it have a problem when it looks throught objects of type House and suddently it finds it mixed with ArrayLists?
I prefer to keep it public so others that search the forums can learn as well, but if you want to send me a private message, that's fine.ok can i send u a private letter on this?
I'm so happy! And I wish to make this tiny ad happy too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|