E220 Two Methods With the Same Name
[Previous]  [Next] 
|
User Manual [Previous]  [Next] E220 Two Methods With the Same NameUmple semantic error related to changing name of a provided method in traits to one which already existsWhen changing the name of provided methods in traits, it is necessary to be sure that there are no other methods with the same names that come from other traits. If the changed name already exists inside of a class, in this case there is no problem becase methods of classes have priority over ones coming from traits. In this case, the method from traits will be disregarded. Otherwise, there is a conflict on the name of methods. The Umple compiler detects this case and raises the error. Example// In this example, there is an error // because in class "A" there will be // two methods with the name "ShowInConsole". class A{ isA T<show() as ShowInConsole>; } trait T{ isA T1; void show(){/*T*/} } trait T1{ void ShowInConsole(){/*T1*/} } Load the above code into UmpleOnline Another Example// In this example, there is an error // because in class "A" there will be // two methods with the name "ShowInConsole". class A{ isA T<show() as ShowInConsole>; isA T1; } trait T{ void show(){/*T*/} } trait T1{ void ShowInConsole(){/*T1*/} } Load the above code into UmpleOnline Solution to The Above So the Message No Longer Appears// In this example, there is no error // because in class "A" // method "ShowInConslole" has high priority. class A{ isA T<show() as ShowInConsole>; isA T1; void ShowInConsole(){ //Implementation } } trait T{ void show(){ //Implementation } } trait T1{ void ShowInScreen(){ //Implementation } } Load the above code into UmpleOnline |