Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace testtttt
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             List<Products> listOfProducts = new List<Products>();
  15.             List<Order> orders = new List<Order>();
  16.  
  17.             for (int i = 0; i < n; i++)
  18.             {
  19.                 string[] input = Console.ReadLine().Split('-').ToArray();
  20.                 var product = new Products
  21.                 {
  22.                     Name = input[0],
  23.                     Price = decimal.Parse(input[1])
  24.                 };
  25.                 var product2 = listOfProducts.FirstOrDefault(x => x.Name == product.Name);
  26.                 if (product2 == null)
  27.                 {
  28.                     listOfProducts.Add(product);
  29.                 }
  30.                 else
  31.                 {
  32.                     product2.Price = product.Price;
  33.                 }
  34.             }
  35.  
  36.             string inputLine = Console.ReadLine();
  37.  
  38.             while (inputLine != "end of clients")
  39.             {
  40.                 string[] orderData = inputLine.Split('-', ',').ToArray();
  41.                 var checkOrder = listOfProducts.FirstOrDefault(x => x.Name == orderData[1]);
  42.                 if (checkOrder != null)
  43.                 {
  44.                     var order = new Order();
  45.                     if (order.Bill[)
  46.                     {
  47.  
  48.                     }
  49.                    
  50.                 }
  51.                 inputLine = Console.ReadLine();
  52.             }
  53.  
  54.             foreach (var item in orders.OrderBy(x => x.Name))
  55.             {
  56.                 Console.WriteLine(item.Name);
  57.  
  58.             }
  59.         }
  60.     }
  61.     class Products
  62.     {
  63.         public string Name { get; set; }
  64.         public decimal Price { get; set; }
  65.     }
  66.  
  67.     class Order
  68.     {
  69.         public string Name { get; set; }
  70.         public Dictionary<Products, int> Bill { get; set; }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement