using System.Collections.Generic;
static void Main(string[] args)
List<Laptop> laptops = new List<Laptop>();
List<Mobile> mobiles = new List<Mobile>();
Console.WriteLine("Press q to show list");
Console.WriteLine("Type: 'mobile' or 'laptop' ");
string type = Console.ReadLine();
if (type.ToLower() == "laptop")
Console.Write("Input Date: ");
string dateInput = Console.ReadLine();
if (dateInput.ToLower().Trim() == "q")
Console.Write("Input Product: ");
string productInput = Console.ReadLine();
if (productInput.ToLower().Trim() == "q")
Console.Write("Input Price: ");
string priceInput = Console.ReadLine();
if (priceInput.ToLower().Trim() == "q")
Laptop laptop = new Laptop(Convert.ToDateTime(dateInput), type, productInput, Convert.ToInt32(priceInput));
if (type.ToLower() == "mobile")
Console.Write("Input Date: ");
string dateInput = Console.ReadLine();
if (dateInput.ToLower().Trim() == "q")
Console.Write("Input Product: ");
string productInput = Console.ReadLine();
if (productInput.ToLower().Trim() == "q")
Console.Write("Input Price: ");
string priceInput = Console.ReadLine();
if (priceInput.ToLower().Trim() == "q")
Mobile mobile = new Mobile(Convert.ToDateTime(dateInput), type, productInput, Convert.ToInt32(priceInput));
List<Laptop> sortedLaptops = laptops.OrderBy(laptop => laptop.Date).ToList();
List<Mobile> sortedMobiles = mobiles.OrderBy(mobile => mobile.Date).ToList();
Console.WriteLine("Date".PadRight(20) + "Type".PadRight(20) + "Product".PadRight(20) + "Price");
DateTime t1 = DateTime.Today;
DateTime currentDate = DateTime.Now;
TimeSpan diff = currentDate -t1;
foreach (Laptop laptop in sortedLaptops)
if(currentDate.AddMonths(-3) >= t1)
Console.WriteLine(currentDate.AddMonths(-3));
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(laptop.Date.ToString("yyyy-MM-dd").PadRight(20) + laptop.Type.PadRight(20) + laptop.Product.PadRight(20) + laptop.Price);
Console.WriteLine(laptop.Date.ToString("yyyy-MM-dd").PadRight(20) + laptop.Type.PadRight(20) + laptop.Product.PadRight(20) + laptop.Price);
foreach (Mobile mobile in sortedMobiles)
Console.WriteLine(mobile.Date.ToString("yyyy-MM-dd").PadRight(20) + mobile.Type.PadRight(20) + mobile.Product.PadRight(20) + mobile.Price);
Console.WriteLine("Press q + Enter to exit or just press Enter to add more laptops");
string decision = Console.ReadLine();
if (decision.ToLower().Trim() == "q")
public Laptop(DateTime date, string type, string product, int price)
public Mobile(DateTime date, string type, string product, int price)
public DateTime Date { get; set; }
public string Type { get; set; }
public string Product { get; set; }
public int Price { get; set; }