Hi All,
I am stuck with this java design problem and need your help on this.
#####################################################
A diamond has 3 attributes and possible values as
Clarity (Y1, Y2, Y3 ......... Y25)
Color (C1, C2, C3 ......... C9)
Carat (T1, T2, T3 ......... T50)
A diamond company deals in diamonds and has definite clients who purchase diamonds from this company.
Each week clients give purchase orders to company for the specific number of diamonds (say 50000). Clients don't give any preference to what (color, clarity or carat) diamonds should be sent to them. Clients just tell companies the number of diamonds they would like to purchase. It is up to companies to decide how many diamonds would be of so n so color (similarly for clarity and carat).
Now, diamond company has to do this exercise (distributing 50000 diamonds order) quite frequently (every week) which eats up a lot of its time.
Company wants to create "templates for diamond distribution" for each of their client so that they can get the distribution of diamonds break up (for Carat, Color and Clarity) by just giving number of diamonds.
Company’s idea of template is as following.
Company can choose any attribute (among Carat, Color and Clarity) as first level of distribution and give percentage distribution at this level.
Company can select any of the two remaining attribute (among Carat, Color and Clarity minus the one chosen in first level of distribution) and add distribution at this level for each distribution of previous level.
Example:
(say, company chose Color as first level and gave following break up
C1 18%
C2 15%
C3 35%
C4 12%
C7 15%
C9 5%
)
Note: distribution percentage values should add up to 100%
And in second level of distribution company chose, clarity.
For each of first level of distribution, it can add percentage distribution for clarity (but it should add 100%).
For C1: (sub distribution percentage values should add up to 100%)
Y1 33%
Y6 33%
Y8 34%
For C2: (sub distribution percentage values should add up to 100%)
Y2 12%
Y7 23%
Y11 20%
Y12 15%
Y21 20%
Y23 10%
For C3: (sub distribution percentage values should add up to 100%)
Y3 40%
Y5 35%
Y7 25%
For C4: (sub distribution percentage values should add up to 100%)
Y9 70%
Y16 30%
For C7: (sub distribution percentage values should add up to 100%)
Y13 10%
Y19 45%
Y23 45%
For C9: (sub distribution percentage values should add up to 100%)
Y3 20%
Y13 10%
Y18 30%
Y22 25%
Y25 15%
Distribution done at 2 levels leaves only one third level of distribution.
Now for each of distribution combination (first and second level), company can add any number of third level possible values and assign percentage distribution to it (again, at this level, for each node combination, total % distribution should add up to 100).
Example continued:
Company will have following combinations as of now till 2nd level of distribution,
C1Y1, C1Y6, C1Y8,
C2Y2, C2Y7, C2Y11, C2Y12, C2Y21, C2Y23,
C3Y3, C3Y5, C3Y7,
C4Y9, C4Y16,
C7Y13, C7Y19, C7Y23,
C9Y3, C9Y13, C9Y18, C9Y22, C9Y25
For each of above nodes, distribution break up can further be given at level 3 as
C1Y1: (sub distribution percentage values should add up to 100%)
T5 16%
T6 16%
T23 16%
T34 16%
T43 16%
T49 20%
and so on...
At the end, company would have percentage distributions of a type of diamond for a certain L1(Clarity)L2(Color)L3(Carat) distribution.
And when percentage values are given and match the validations (for each Level1 breakup there should be a further Level2 breakup and for each Level2 breakup there should exist a further Level3 breakup and all invidual breakups should add up to 100%).
This template can be saved in the database and can be reused any number of time.
Company will just give number of diamond (say 100000) as input to this template and will get the distribution back.
Any decimal value of diamond will always be rounded up. so at the end, company will get back the numbered distribution for this template.
End distribution can be more than input number (1000) as we will be rounding up the decimal values, but that is accepted.
Can you suggest a suitable java data structure, algorithm, java code and database (if possible) to get the distribution?
#####################################################
Thanks