public void BuildShips(Ship toBuild, int quantity) { string message = ""; //grammatical mistakes from task desciption are left if (Metal < toBuild.Metal * quantity) { message = $"{Name} have not resource metal to build a {toBuild.Name} {quantity} units."; } else if (Mineral < toBuild.Mineral * quantity) { message = $"{Name} have not resource mineral to build a {toBuild.Name} {quantity} units."; } else { Metal -= toBuild.Metal * quantity; Mineral -= toBuild.Mineral * quantity; for (int i = 0; i < quantity; i++) { ShipsList.Add(toBuild); } message = $"On {Name} was builded {toBuild.Name} {quantity}"; } Console.WriteLine(message); }
public Ship GetVesselFromImoString(string imo) { var ship = (ShipsList.Any(s => s.Imo == $"IMO{imo}") ? ShipsList.First(x => x.Imo == $"IMO{imo}") : null) ?? ShipsList.First(x => x.Imo == "IMO0"); return(ship); }
public Ship GetVesselFromName(string name) { return(ShipsList.FirstOrDefault(p => p.Name == name)); }