Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace _07._StoreBoxes
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- List<Box> boxes = new List<Box>();
- while (input != "end")
- {
- string[] tokens = input.Split();
- Item item = new Item(tokens[1], //Item Name
- decimal.Parse(tokens[3])); //ItemPrice
- Box box = new Box(tokens[0], //Serial Number
- item, //Item Name , ItemPrice
- int.Parse(tokens[2])); //Item Quantity
- boxes.Add(box);
- input = Console.ReadLine();
- }
- List<Box> sortedBoxes = SortBoxes(boxes);
- foreach (var box in boxes)
- {
- Console.WriteLine($"{box.SerialNumber}");
- Console.WriteLine($"-- {box.Item.Name} – " +
- $"${box.Item.Price}: " +
- $"{box.ItemQuantity}");
- Console.WriteLine($"{box.PriceForBox}");
- }
- }
- private static List<Box> SortBoxes(List<Box> boxes)
- {
- List<Box> sortedBoxes = new List<Box>();
- for (int i = 0; i < boxes.Count; i++)
- {
- }
- return sortedBoxes;
- }
- }
- class Item
- {
- public Item(string name, decimal price)
- {
- Name = name;
- Price = price;
- }
- public string Name { get; set; }
- public decimal Price { get; set; }
- }
- class Box
- {
- public Box(string serialNumber,
- Item item,
- int itemQuantity)
- {
- SerialNumber = serialNumber;
- Item = item;
- ItemQuantity = itemQuantity;
- PriceForBox = item.Price * ItemQuantity;
- }
- public string SerialNumber { get; set; }
- public Item Item { get; set; }
- public int ItemQuantity { get; set; }
- public decimal PriceForBox { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement