list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

E097 Enumeration and State Machine Conflict

Umple semantic error reported when an enumeration, and a state machine within the same class have the same name.

In Umple, enumerations and state machines within the same class cannot have the same name.

Example

  1. // This example generates the error  
  2. // because enumeration "Y" has the  
  3. // same name as state machine "Y"  
  4.   
  5. class X {  
  6.  enum Y { Red, Blue, Green }  
  7.  Y {  
  8.   s1 {   
  9.     goToS2 -> s2;  
  10.   }  
  11.   s2 { }  
  12.  }  
  13. }  
  14.         

Load the above code into UmpleOnline

 

Another Example

  1. // This example generates the error  
  2. // because enumeration "Y" will be   
  3. // added to class "X" since the "attr"  
  4. // parameter of "showY" is "Y".  
  5.   
  6. enum Y { Red, Blue, Green }  
  7.   
  8. class X {  
  9.   showY(Y attr) {  
  10.     System.out.println(attr); }  
  11.   Y {  
  12.    s1 {}  
  13.   }  
  14. }  
  15.         

Load the above code into UmpleOnline

 

Solution to The Above So the Message No Longer Appears

  1. // This example does not generate the error  
  2.   
  3. class X {  
  4.  enum Y { Red, Blue, Green }  
  5.  Z {  
  6.   s1 {   
  7.     goToS2 -> s2;  
  8.   }  
  9.   s2 { }  
  10.  }  
  11. }  
  12.         

Load the above code into UmpleOnline