using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Expenses { class Expense { private string[] categories = { "Travel", "Entertainment", "Office" }; private static Random rand1 = new Random(); public string Category { get; set; } public decimal Cost { get; set; } public DateTime Date { get; set; } public Expense() { Category = categories[rand1.Next(0, 3)]; decimal i = (decimal)rand1.Next(1, 10001)/100; Cost = i; Date = DateTime.Today.AddDays(-rand1.Next(0, 32)); } public Expense(string category, decimal cost, DateTime date) { this.Category = category; this.Cost = cost; this.Date = date; } public override string ToString() { return Category + " " + String.Format("{0:C}", Cost) + " on " + Date.ToShortDateString(); } } }
↧
tips from vivion
↧