Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

tips from vivion

$
0
0
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(); 
        }


    }
}


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>