public IMoney GetMoneyToDisplay(MoneyType form) { if (this.moneyObjects == null) { this.moneyObjects = new Dictionary<MoneyType, IMoney>(); } if (this.moneyObjects.ContainsKey(form)) { return this.moneyObjects[form]; } switch (form) { case MoneyType.Metalic: this.moneyObjects.Add(form, new MetalicMoney()); this.ObjectCount++; break; case MoneyType.Paper: this.moneyObjects.Add(form, new PaperMoney()); this.ObjectCount++; break; default: throw new ArgumentException("Unsupported money type"); } return this.moneyObjects[form]; }
public MoneyFlowUnit(int AccID, double Count, int CategoryID, string UserComment, DateTime Date, MoneyType type) { _Account_Id = AccID; _Count = Count; _Category = CategoryID; _Comment = UserComment; _Date = Date; _type = type; }
static double GetBaseValue(MoneyType moneyType) { switch (moneyType) { case MoneyType.Copper: return BASE_VALUE * COPPER_BASE_VALUE; case MoneyType.Silver: return BASE_VALUE * SILVER_BASE_VALUE; case MoneyType.Gold: return BASE_VALUE * GOLD_BASE_VALUE; case MoneyType.Platinum: return BASE_VALUE * PLATINUM_BASE_VALUE; case MoneyType.Diamond: return BASE_VALUE * DIAMOND_BASE_VALUE; case MoneyType.Chrona: return BASE_VALUE * CHRONA_BASE_VALUE; default: return BASE_VALUE; } }
//para biriminleri arasında convert işlemlerimizi bu metod vasıtasıyla //yapacağız. Sadece çevirmek istediğimiz para birimini hassasiyet bilgisini //veriyoruz. public Money ConvertToMoney(MoneyType type,int roundSensitive) { //eğer çevrilmesini istediğimiz tip ile aynı tip ise aynı tipi dönüyoruz. if (Enum.Equals(moneyType, type)) return this; else { //Toplam TL tutar bulundu. decimal totalTlValue = this.amount * this.Rate; //istenen tipin rate değeri bulunmadı. decimal convertRateValue = GetMoneyRate(type); //istenen kur tipinden toplam amount miktarı hesaplandı. decimal convertAmount = Math.Round(totalTlValue / convertRateValue, roundSensitive); //yeni para birimi ve amounta göre paramız oluştuurlur. Money returnMoney = new Money(type,convertAmount); return returnMoney; } }
//yapıcı metodumuzda sadece para birimi ve miktarını alıyoruz. public Money(MoneyType type, decimal amount) { this.amount = amount; this.moneyType = type; }
//bu metodun sanki ilgili günün rate bilgilerini //döndüğünü düşünüyoruz private decimal GetMoneyRate(MoneyType type) { //burada paranın kur bilgilerinin alındığını düşünüelim. decimal rate = 0; switch (type) { case MoneyType.TL: rate = 1M; break; case MoneyType.Dollar: rate = 2.35M; break; case MoneyType.Euro: rate = 2.95M; break; case MoneyType.GBP: rate = 3.35M; break; case MoneyType.JPY: rate = 0.55M; break; default: rate = 1M; break; } return rate; }
public static ItemPrice ConvertPriceTo(MoneyType moneyType, ItemPrice itemPrice) { return new ItemPrice(itemPrice.Value * (GetBaseValue(itemPrice.MoneyType) / GetBaseValue(moneyType))); }
public Account(MoneyType type) { Id = Guid.NewGuid().ToString(); Balance = 0; Type = type; }
public MoneyItemModel(string name, float weight, float value, float maxCondition, int maxQuantity, bool hidden, bool essential, string[] flags, ItemScriptNode scripts, string worldModel, MoneyType type) : base(name, weight, value, maxCondition, maxQuantity, hidden, essential, flags, scripts, worldModel) { Type = type; Stackable = true; }