Good evening!
I'm still learning
java and tonight I'm stumbling over the way my teacher used the iterator method of the interface Collection.
Indeed, my teacher defined such a following value method of a class of elements HashConcret:
I don't see any elements being passed as arguments, entering it the iterator... to have their value being moved up to the sum!
So does it actually work? And if it does, how?
[table="width: 500, class: outer_border"]
[tr]
[td]
Class Composant is
abstract and defined the characteristics of a named given composant. It is characterized by a name and realize two interfaces Named and Valuable defined below. Two composants are equals if they have same name and same value.
Class Atome is a composant characterized by a name and a double value. An atome is equal to another atome if they have same value. The name of an atome is not given at creation. it is formed by its parent's name. followed by "_" and its value.
Abstract class Composite is defined by the characteristics of a complex composant having a collection of named elements of type Atome or Coposite. The class composite forbidden dupplicates. It realizes the interface ComposantManagement. Two objects are equals if they have same name and same elements.
Class HashConcret is a subclass of Composite which doesn't allow to have duplications and which elements aren't sorted out. The value of an instance of HashConcret is the mean of the value of its elements.[/td]
[/tr]
[/table]
this description corresponds to the following code:
HashConcret is at the bottom!
I want to understand the method
value() of
class Composite.