public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendLine("<Gold> $" + Gold); sb.AppendLine("##Gold - " + Gold); var gemsTotal = Gems.Sum(g => g.Quantity); if (gemsTotal > 0) { sb.AppendLine("<Gem> $" + gemsTotal); foreach (var gem in Gems.OrderByDescending(g => g.Name).ThenBy(g => g.Quantity)) { sb.AppendLine($"##{gem.Name} - {gem.Quantity}"); } var cashTotal = Cash.Sum(c => c.Quantity); if (cashTotal > 0) { sb.AppendLine("<Cash> $" + cashTotal); foreach (var cash in Cash.OrderByDescending(g => g.Currency).ThenBy(g => g.Quantity)) { sb.AppendLine($"##{cash.Currency} - {cash.Quantity}"); } } } return(sb.ToString()); }
public override string ToString() { var builder = new StringBuilder(); if (Gold.Any()) { builder.AppendLine($"<Gold> ${GoldAmount}"); builder.AppendLine($"##Gold - {GoldAmount}"); } if (Gems.Any()) { builder.AppendLine($"<Gem> ${GemsAmount}"); foreach (var gem in Gems.OrderByDescending(g => g.Value.Name).ThenBy(g => g.Value.Amount)) { builder.AppendLine($"##{gem.Value.Name} - {gem.Value.Amount}"); } } if (AllCash.Any()) { builder.AppendLine($"<Cash> ${CashAmount}"); foreach (var cash in AllCash.OrderByDescending(c => c.Value.Name).ThenBy(c => c.Value.Amount)) { builder.AppendLine($"##{cash.Value.Name} - {cash.Value.Amount}"); } } return(builder.ToString()); }
public override string ToString() { StringBuilder bagContents = new StringBuilder(); if (Gold > 0) { bagContents.AppendLine($"<Gold> ${Gold}"); bagContents.AppendLine($"##Gold - {Gold}"); } if (GemsTotal > 0) { bagContents.AppendLine($"<Gem> ${GemsTotal}"); foreach (Gem gem in Gems .OrderByDescending(g => g.Type).ThenBy(g => g.Amount)) { bagContents.AppendLine(gem.ToString()); } } if (CashTotal > 0) { bagContents.AppendLine($"<Cash> ${CashTotal}"); foreach (Currency currency in Cash .OrderByDescending(c => c.Type).ThenBy(c => c.Amount)) { bagContents.AppendLine(currency.ToString()); } } return(bagContents.ToString().TrimEnd()); }
public List <List <string> > ArrangeItems() { var dic = new Dictionary <List <string>, long>(); var goldAmount = GetGoldAmount(); var goldPrefix = new List <string>(); goldPrefix.Add("<Gold> $" + goldAmount); Gold = Gold.OrderByDescending(g => g.Name).ThenBy(g => g.Value).ToList(); var gold = goldPrefix.Concat(Gold.Select(g => $"##{g.Name} - {g.Value}").ToList()).ToList(); if (gold.Count > 1) { dic.Add(gold, goldAmount); } var gemsAmount = GetGemsAmount(); var gemsPrefix = new List <string>(); gemsPrefix.Add("<Gem> $" + gemsAmount); Gems = Gems.OrderByDescending(g => g.Name).ThenBy(g => g.Value).ToList(); var gems = gemsPrefix.Concat(Gems.Select(g => $"##{g.Name} - {g.Value}").ToList()).ToList(); if (gems.Count > 1) { dic.Add(gems, gemsAmount); } var cashAmount = GetCashAmount(); var cashPrefix = new List <string>(); cashPrefix.Add("<Cash> $" + cashAmount); Cash = Cash.OrderByDescending(c => c.Name).ThenBy(c => c.Value).ToList(); var cash = cashPrefix.Concat(Cash.Select(g => $"##{g.Name} - {g.Value}").ToList()).ToList(); if (cash.Count > 1) { dic.Add(cash, cashAmount); } return(dic .OrderByDescending(v => v.Value) .Select(e => e.Key) .ToList()); }