private void Sell() { List <SpaceBody> _spaceBodies = PlayerSingleton.GetSpaceBodies(); if (_spaceBodies.Count == 0) { Console.WriteLine("You got nothing to sell\n"); return; } ; Console.WriteLine("Player's Spacebodies: "); for (int i = 0; i < _spaceBodies.Count; i++) { Console.WriteLine("[{0}] {1}", i, string.Format("Name: {0}, Price: {1} $", _spaceBodies[i].getName(), _spaceBodies[i].getPrice())); } Console.WriteLine("\nWhat Spacebody do you want to sell? (Write with number)"); input = Console.ReadLine(); if (int.TryParse(input, out int option)) { if (_spaceBodies.Count < option) { Console.WriteLine("Doesn't exist"); return; } else { SpaceBody soldItem = _spaceBodies[option]; PlayerSingleton.RemoveSpaceBody(option); double sellingPrice = Math.Round((soldItem.getPrice() * 0.80), 2); PlayerSingleton.AddMoney(sellingPrice); Console.WriteLine("Sold {0} for {1} $", soldItem.getName(), sellingPrice); } } }
public static void AddSpaceBody(SpaceBody spaceBody) { spaceBodies.Add(spaceBody); }