Deserboy

Object and Classes - Store Boxes Error

Jul 18th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5.  
  6. namespace Objects_and_Classes
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. List<Box> boxInformation = new List<Box>();
  13. List<Item> itemInformation = new List<Item>();
  14. string input = Console.ReadLine();
  15. while (input != "end")
  16. {
  17. string[] tokens = input.Split(" ");
  18. int serial = int.Parse(tokens[0]);
  19. string name = tokens[1];
  20. int quantity = int.Parse(tokens[2]);
  21. double price = double.Parse(tokens[3]);
  22. double boxPrice = quantity * price;
  23. Box box = new Box();
  24. Item item = new Item();
  25. item.Name = name;
  26. item.Price = price;
  27. box.Serial = serial;
  28. box.Item = name;
  29. box.Quantity = quantity;
  30. box.Price = boxPrice;
  31. boxInformation.Add(box);
  32. itemInformation.Add(item);
  33. input = Console.ReadLine();
  34. }
  35. boxInformation.Sort();
  36. boxInformation.Reverse();
  37. foreach (Box box in boxInformation)
  38. {
  39. Console.WriteLine(box.Serial);
  40. Console.WriteLine($"-- {box.Item} - {itemInformation.}");
  41. }
  42. }
  43. }
  44. }
  45. namespace Objects_and_Classes
  46. {
  47. class Item
  48. {
  49. public string Name { get; set; }
  50. public double Price { get; set; }
  51. }
  52. }
  53. namespace Objects_and_Classes
  54. {
  55. class Box
  56. {
  57. public int Serial { get; set; }
  58. public Item Item { get; set; }
  59. public int Quantity { get; set; }
  60. public double Price { get; set; }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment