What do you think about that diagram?

2019-07-17 20:06发布

问题:

Could you please tell me if my diagram is correct? I especially care about relations between PaymentService and Customer, Payment, Customer

I guess that:

   class Customer {
     private List<Payment> payments;
     //..
     public boolean pay() {
       return PaymentService.pay(this.payments);
       // calling the static method of the class PaymentService
     }
   }

   interface Payment {
     // knows nothing about Customer
   }

   class PaymentService {
     public static boolean pay (List<ayment> payments) {
       // the magic here is return result
     }
   }


UPD: Now, I noticed that why I use static member, but it does not touch my question.

What is the common way to construct payment systems (It looks like a general task)?


I guess that the FFCustomer should have only one account. And an account exists only while an FFCustomer exists.

UPD:

回答1:

It's pretty close. Make the association to Payment unidirectional. Make the account property an association end. In general, attributes should only be typed by datatypes, not classes. You are also missing an operation in the Payment interface.