0

This image illustrate the UML I must follow in this project.

The problem is, I don't know what means the private parameter "ator" in the arrow. It should be declared in the class Ator or Personagem? I do know that Personagem is a subclass of Ator.

JChris
  • 1,638
  • 5
  • 19
  • 37

1 Answers1

0

Because the arrow is unidirectional, you can be sure that -ator should be placed just next to the Ator class. This implies that a private attribute ator exists for class Personagem.

Then, from any method in the Personagem class, you can use some code like this.ator.getId()

Bastien Pasdeloup
  • 1,089
  • 12
  • 19
  • So the -ator should be declared in Ator class? Is that what it means this being in the arrow? But it is private, how can I access it in Personagem class? – JChris Nov 23 '13 at 01:50
  • Nope, the code resulting from your diagram will be two classes: (1) Ator (with attributes `id` and `nome`). (2) Personagem (with attributes `nome` and `ator`). The arrow indicates that only the class `Personagem` will have an attribute of class `Ator`, and not the contrary. The fact that it is private only means that you will be able to access the `ator` attribute in class `Personagem` from the class `Personagem` itself only. If you want to access it from somewhere else, you will have to call the getter method `getAtor()`. – Bastien Pasdeloup Nov 23 '13 at 11:16
  • I found this link, if that can help: http://stackoverflow.com/questions/15487372/bi-directional-and-uni-directional-associations-uml – Bastien Pasdeloup Nov 23 '13 at 11:19
  • Just a little question. In this example, Personagem must extends Ator, accordingly to the UML, right? – JChris Nov 23 '13 at 12:59
  • Nope, Arrows for generalization have a white triangle in the end (see http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/bell_fig5.jpg for instance). The arrow in your diagram is an unidirectional assiciation. – Bastien Pasdeloup Nov 23 '13 at 13:47