I would say that someone has understood UML upside down, and it isn't you: the UML specification (UML Superstructure Specification, v2.4.1 pag. 504) defines a CallEvent
(i.e. arrow) as the reception by an object of a message invoking a call of an operation. For instance, see here.
My understanding is that the given diagram does not represent the given code.
- In the diagram, it is the
Customer
who sends anadd order item
to theDinner Now System
(makes sense) - In the code, it is the
onlinemealsellingsystem
sends aaddOrderItems
to theCustomer
(doesn't make sense).
Leaving aside the parameters (since they are not specified in your examplethe source code corresponding to the diagram would be similar to:
class Customer {
public void iWannaEat() {
DinnerNowSystem dns =new DinnerNowSystem();
Restaurant r = new Restaurant();
Bank b = new Bank();
while (...) dns.addOrderItem();
dns.confirmOrder();
dns.sendorder();
dns.paymentDetail();
Food f = r.receiveFood();
}
}
class DinnerNowSystem() {
Bank b;
Restaurant r;
void addOrderItem();
void confirmOrder() {
r.sendOrder();
}
void paymentDetail() {
if (b.processPayment())
r.confirmOrder()
else halt and catch fire;
}
}
Note also that, if the code and the UML diagram that you posted are corresponding each other, the code misses the loop
that is present in the diagram. That is just weird.
Note also that it is the Customer
who waits until the Restaurant
delivers it the food.