Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- namespace Objects_and_Classes
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Box> boxInformation = new List<Box>();
- List<Item> itemInformation = new List<Item>();
- string input = Console.ReadLine();
- while (input != "end")
- {
- string[] tokens = input.Split(" ");
- int serial = int.Parse(tokens[0]);
- string name = tokens[1];
- int quantity = int.Parse(tokens[2]);
- double price = double.Parse(tokens[3]);
- double boxPrice = quantity * price;
- Box box = new Box();
- Item item = new Item();
- item.Name = name;
- item.Price = price;
- box.Serial = serial;
- box.Item = name;
- box.Quantity = quantity;
- box.Price = boxPrice;
- boxInformation.Add(box);
- itemInformation.Add(item);
- input = Console.ReadLine();
- }
- boxInformation.Sort();
- boxInformation.Reverse();
- foreach (Box box in boxInformation)
- {
- Console.WriteLine(box.Serial);
- Console.WriteLine($"-- {box.Item} - {itemInformation.}");
- }
- }
- }
- }
- namespace Objects_and_Classes
- {
- class Item
- {
- public string Name { get; set; }
- public double Price { get; set; }
- }
- }
- namespace Objects_and_Classes
- {
- class Box
- {
- public int Serial { get; set; }
- public Item Item { get; set; }
- public int Quantity { get; set; }
- public double Price { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment