Guest User

Untitled

a guest
Jun 17th, 2017
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. string product = input[0];
  2. double productPrice = double.Parse(input[1]);
  3. int productQuantity = int.Parse(input[2]);
  4. //проверка за ключа на главния речник
  5. if (!supermarketDatabases.ContainsKey(prouct))
  6. {
  7. supermarketDatabases.Add(product, new Dictionary<double, int>());
  8. }
  9. //проверка за ключа на вложения
  10. if(!supermarketDatabases[product].ConstainsKey(productPrice))
  11. {
  12. supermarketDatabases[product].Add(productPrice, 0);
  13. }
  14. //тук вече ти е другата логика (дали ще заместваш ст-ста или ще я събираш, изваждаш и т.н.),
  15. //другия вариант е на горния ред вместо 0 да ти е productQuantity, а този ред да ти е с else
  16. supermarketDatabases[product][productPrice] = productQuantity
Advertisement
Add Comment
Please, Sign In to add comment