public static void Main(string[] args) { Pirate John = new Pirate("John"); Pirate Marty = new Pirate("Marty"); Console.WriteLine(); John.DrinkSomeRum(); Console.WriteLine(); John.Brawl(Marty); PirateShip myShip = new PirateShip(); myShip.AddPirate(Marty, "crew"); myShip.AddPirate(John, "captain"); myShip.AddPirate(John, "captain"); myShip.ShipStatus(); }
public void AddPirate(Pirate pirate, string crewOrCaptain) { if (crewOrCaptain == "captain") { if (hasCaptain == true) { Console.WriteLine("The ship already has a captain."); Console.WriteLine(); } else { pirateShip.Insert(0, pirate); hasCaptain = true; Console.WriteLine($"{pirate.name} was added as the ship's captain"); Console.WriteLine(); pirate.isCaptain = true; } } else { pirateShip.Add(pirate); Console.WriteLine($"{pirate.name} was added to the ship's crew!"); } }