The retail programming challenge of

How to help the seller to determine whether there is a product with the desired characteristics? 3r3162.  
Example [/b]
Often, having come to the shoe store and choosing the model you like, we wait for the sellers to determine if there is a suitable size 3r3162.  
3r3162.  

Given

3r3162.  
List of
variations r3r321. . Each variation in turn contains a list of attributes and their values. 3r3162.  
example-data.json [/b]
[
{
"Size": 37,
"Color": "Brown",
"Lock": "Zipper"
},
{
"Size": 37,
"Color": "Black",
"Lock": "Zipper"
},
{
"Size": 38,
"Color": "Blue",
"Lock": "Laces"
},
{
"Size": 39,
"Color": "Blue",
"Lock": "Laces"
},
{
"Size": 39,
"Color": "Brown",
"Lock": "Zipper"
},
{
"Size": 39,
"Color": "Brown",
"Lock": "Laces"
},
{
"Size": 40,
"Color": "Brown",
"Lock": "Laces"
}
]

3r3162.  
It is necessary to create an interface by which the seller, having selected the necessary properties, can determine whether the goods are in stock or not. 3r3162.  
3r375. 3r33175. 3r3162.  

Conditions: 3r3398. 3r3162.  
3r3148.  
The variation contains the complete list of attributes (there can be no variation with unknown values, if the attribute is present in one variation, then it is in all) 3r33240.  
The length of the list of options for attribute values ​​varies from attribute to attribute (one attribute can take one of two values, the other one of four, etc.) 3r34040.  
One attribute can have only one value
 
3r3162.  
Functional:

3r3162.  
The interface is a list of lists, where at the first level is an attribute type, at the second its value. 3r3162.  
3r3162.  
Each element can be in 3 states:
 
3r3148.  
Available for selection - White
 
Active - Blue
 
Available in other combinations - Gray
 
3r3162.  
At the beginning, all items are available for selection
 
The retail programming challenge of 3r3162.  
3r3162.  
After selecting one of the attributes, all the others are revised. 3r3162.  
3r33130. 3r3162.  
We chose 37. All other sizes are white (as they are by condition). Blue is not. It becomes gray, the rest are white. 37 is only on the Lightning. So lightning is automatically selected. [b] And here, attention! 3r3133. There is no 40 lightning bolt, so 40 becomes gray. 3r3162.  
3r3162.  
If we suddenly needed a blue color, then the size is reset (since there is no blue 37) and the lock (since there is no 37 lightning, if it were, it would remain selected), the laces are automatically selected (since blue There is only with laces), and the sizes become available 3? 39. 3r3r1616.  
3r3141. 3r3162.  
3r3162.  
The task is applicable as:
 
3r3148.  
Practice for learners programming
 
Test task for the selection of candidates
 
Just an interesting pastime for experienced developers 3r3240.  
3r3162.  
3r3162.  
Please: do not post in the comments the solution of the problem 3r3252.
3r3167. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d! ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () (); 3r3168.
3r3173. Only registered users can participate in the survey. 3r3174. Enter
, you are welcome. 3r3176.
3r3179.
3r3181.
3r3183. The task for the developer level
3r3189.
3r3191.
3r3193.
3r3195.
3r3198.
Junior
Middle
Sinyor
29 users have voted. Abstained 9 users.
+ 0 -

Add comment