public bool isLessThan(Money money) { decimal amount = this.ConvertToMoney(MoneyType.TL, 2).amount; decimal otherAmount = money.ConvertToMoney(MoneyType.TL, 2).amount; decimal div = otherAmount - amount; div = div > 0 ? div : -1 * div; return(div > 0.01M); }
public static void Main(string[] args) { Console.WriteLine("Change types"); Console.ForegroundColor = ConsoleColor.Cyan; decimal amountChangeEurToUsd = 1.193985m; Console.WriteLine($"EUR to USD => {amountChangeEurToUsd}"); decimal amountChangeEurToGbp = 0.915578931m; Console.WriteLine($"EUR to GBP => {amountChangeEurToGbp}"); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Money moneySpain = new Money(749m, CurrencyOf.EurType); Product product = new Product("Microsoft", "Surface Pro 4", moneySpain); ProductToString(product); Money moneyUnitedStates = moneySpain.ConvertToMoney(CurrencyOf.UsdType, amountChangeEurToUsd); product = new Product(product.Trademark, product.Name, moneyUnitedStates); ProductToString(product); Money moneyBritish = moneySpain.ConvertToMoney(CurrencyOf.GbpType, amountChangeEurToGbp); product = new Product(product.Trademark, product.Name, moneyBritish); ProductToString(product); decimal amountChangeUsdToEur = 0.83753146m; Money moneyUSA = new Money(894.294765m, CurrencyOf.UsdType); Money moneyES = moneyUSA.ConvertToMoney(CurrencyOf.EurType, amountChangeUsdToEur); product = new Product(product.Trademark, product.Name, moneyES); ProductToString(product); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("Press any key to close"); Console.ReadKey(); }
//mevcut paramıza yeni para eklemeye yarayan metod //örneğin Euro olan bir paraya dollar eklenebilir. public bool AddMoney(Money money) { //önce mevcut paranın tl cinsinden tutarı bulunur. decimal tlAmount=this.ConvertToMoney(MoneyPattern.MoneyType.TL, 2).amount; //daha sonra eklenmek istenen paranın tl cinsinden tutarı bulunur. decimal otherTlAmount = money.ConvertToMoney(MoneyPattern.MoneyType.TL, 2).amount; //daha sonra bu iki paranın toplamı mevcut sınıfımızın currency değerine çevrilir. decimal lastAmount = Math.Round((tlAmount + otherTlAmount) / this.GetMoneyRate(this.moneyType), 2); //amoutumuz güncellenir. this.amount = lastAmount; return true; }
//mevcut paramıza yeni para eklemeye yarayan metod //örneğin Euro olan bir paraya dollar eklenebilir. public bool AddMoney(Money money) { //önce mevcut paranın tl cinsinden tutarı bulunur. decimal tlAmount = this.ConvertToMoney(MoneyPattern.MoneyType.TL, 2).amount; //daha sonra eklenmek istenen paranın tl cinsinden tutarı bulunur. decimal otherTlAmount = money.ConvertToMoney(MoneyPattern.MoneyType.TL, 2).amount; //daha sonra bu iki paranın toplamı mevcut sınıfımızın currency değerine çevrilir. decimal lastAmount = Math.Round((tlAmount + otherTlAmount) / this.GetMoneyRate(this.moneyType), 2); //amoutumuz güncellenir. this.amount = lastAmount; return(true); }
static void Main(string[] args) { //1000 euro oluşturulur Money euroMoney = new Money(MoneyType.Euro, 1000); //600 dollar oluşturulu Money dollarMoney = new Money(MoneyType.Dollar, 600); //1000 euroya 600 doları ekleyelim. euroMoney.AddMoney(dollarMoney); //eouro muzu gbp ye convert edelim. Money gbpMoney=euroMoney.ConvertToMoney(MoneyType.GBP, 2); //gbp değerimizi yüzdelerimizi vererek 3 e bölelim List<Money> gbpMoneyList=gbpMoney.DivideMoney(3, 30, 40, 30); //dolarımız birinci gbp değerinden büyük mü kontrolünü yapalım. dollarMoney.isGreaterThan(gbpMoneyList[0]); }
public bool isLessThan(Money money) { decimal amount = this.ConvertToMoney(MoneyType.TL, 2).amount; decimal otherAmount = money.ConvertToMoney(MoneyType.TL, 2).amount; decimal div = otherAmount-amount; div = div > 0 ? div : -1 * div; return div > 0.01M; }