Advertisement
Again_89

Vapor Winter Sale

Apr 13th, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _01._Vapor_Winter_Sale
  6. {
  7. class GameWithDLC
  8. {
  9. public string GameName { get; set; }
  10.  
  11. public string DLC { get; set; }
  12.  
  13. public decimal Price { get; set; }
  14. }
  15. class Program
  16. {
  17. static void Main()
  18. {
  19. var input = Console.ReadLine().Split(", ");
  20.  
  21. var games = new Dictionary<string, decimal>();
  22. var gamesWithDLC = new List<GameWithDLC>();
  23.  
  24. for (int i = 0; i < input.Length; i++)
  25. {
  26. var command = input[i];
  27. if (command.Contains("-"))
  28. {
  29. var data = command.Split("-");
  30. var gameName = data[0];
  31. var price = decimal.Parse(data[1]);
  32. games[gameName] = price;
  33. }
  34. else if (command.Contains(":"))
  35. {
  36. var data = command.Split(":");
  37. var gameName = data[0];
  38. var DLC = data[1];
  39. if (games.ContainsKey(gameName))
  40. {
  41. var price = games[gameName] * 1.2m * 0.5m;
  42. var game = new GameWithDLC();
  43. game.GameName = gameName;
  44. game.DLC = DLC;
  45. game.Price = price;
  46. gamesWithDLC.Add(game);
  47.  
  48. games.Remove(gameName);
  49. }
  50. }
  51. }
  52.  
  53. foreach (var game in gamesWithDLC.OrderBy(x => x.Price))
  54. {
  55. Console.WriteLine($"{game.GameName} - {game.DLC} - {game.Price:F2}");
  56. }
  57.  
  58. foreach (var game in games.OrderByDescending(x => x.Value))
  59. {
  60. Console.WriteLine($"{game.Key} - {(game.Value * 0.8m):F2}");
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement