UML 2.0 & Model-Driven Architectures
by Lars Mats



Figure 2:
      PhoneBook                         Contact
part contact : Contact [*]       contact
static main()                         *


Figure 3:

class PhoneBook {
   static void main() {
      (new PhoneBook()).doMainLoop();
   }
   private void doMainLoop() {
      while (dispatchCommand())
        ;
   }
   private boolean dispatchCommand();
   Contact contact;
}


Figure 4:

class PhoneBook {
   static void main() {
      (new PhoneBook()).doMainLoop();
   }
   private void doMainLoop() {
      while (dispatchCommand())
        ;
   }
   private boolean dispatchCommand();
        //...
   Contact findContact(String name) {
      for (int n=0; n<nContacts;++n){
         if(arrContact[n].name==name)
            return arrContact[n];
      }
      return null;
   }
   Contact[] arrContact;
   int nContacts;
}

Figure 5:

class PhoneBook {
   static void main() {
      (new PhoneBook()).doMainLoop();
   }
   private void doMainLoop() {
      while (dispatchCommand())
        ;
   }
   private boolean dispatchCommand();
        //...
   Contact findContact(String name) {
      for (int index=0; index<nContacts;++index){
         if(m_contacts[index].name==name)
            return m_contacts[index];
      }
      return null;
   }
   Contact[] m_Contacts;
   int nContacts;
}







2


