mardi 9 janvier 2018

using Composite Pattern to count the number of people in the world

I'm trying to make a Composite Pattern that counts the number of people in the world, the continent, the state ...

Here is the pattern that I follow:enter image description here

And I did this:enter image description here

but I am not sure it's right, because can I use leaf -> population ?

Because when I did Composite Pattern for PC so its (PC= component from PC will be Cabinet = composite, from Cabinet will be HDD= leaf and Motherboard = composite, from Motherboard will be RAM = leaf and CPU = leaf). What I want to say every leafs are different and in my diagram are same.

and you think I have something good at least.

Maybe this solution is better:

enter image description here

Thank you for your answers :)

Aucun commentaire:

Enregistrer un commentaire