Rui
Rui

Reputation: 127

draw uml class diagram with both super class object and subclass object being called in a third class

I have a Class A which is the super class of the class B (that is public class B extends A). Now I have a another class C, Class A is a instance variable in class C and class B is being downcasted from Class A and being assign to a local variable in class C. How should I represent this relationship in a uml class diagram?

Upvotes: 1

Views: 1123

Answers (1)

Christophe
Christophe

Reputation: 73456

The class-diagram is straightforward:

enter image description here

Tha association of C with A is structural, since there is an instance variable of that type.

The fact that an operation of C performs a downcast from the instance variable to B in a local variable, does not change the class diagram: the class diagram is about the structure, and not about what may happen temporary during the execution of the one or the other methods.

Upvotes: 1

Related Questions