public Boat GetInput(Boat boatToUpdate = null) { if (boatToUpdate != null) { WriteLine($"You are updating a boat with type of {boatToUpdate.GetTypeString()} and length of {boatToUpdate.Length}m"); } string isNew = boatToUpdate != null ? " new " : ""; WriteLine($"Choose{isNew} boat type:"); WriteLine("Enter: 1 for Sailboat"); WriteLine(" 2 for Motorsailer"); WriteLine(" 3 for Kayar/Canoe"); WriteLine(" 4 for Other"); Write("Your Choice: "); Boat.BoatType type = (Boat.BoatType)Enum.Parse(typeof(Boat.BoatType), ReadLine()); if (!Enum.IsDefined(typeof(Boat.BoatType), type)) { WriteLine("That is not a correct type, please try again."); GetInput(boatToUpdate); } WriteLine($"Enter{isNew} boat length in meters:"); int length = Convert.ToInt32(ReadLine()); return new Boat(type, length); }
public void RemoveBoat(Boat boat) { Boats.Remove(boat); SaveBoats(); }
public void EditBoat(Boat oldBoat, Boat newBoat) { int index = Boats.IndexOf(oldBoat); Boats[index] = newBoat; SaveBoats(); }
public void AddBoat(Boat boat) { Boats.Add(boat); SaveBoats(); }
public void UpdateBoatOnMember(Member member, Boat oldBoat, Boat newBoat) { Member foundMember = MemberList.Find(m => m == member); foundMember.EditBoat(oldBoat, newBoat); Save(); }
public void RemoveBoatFromMember(Member member, Boat boat) { Member foundMember = MemberList.Find(m => m == member); foundMember.RemoveBoat(boat); Save(); }
public void AddBoatToMember(Member member, Boat boat) { Member foundMember = MemberList.Find(m => m == member); foundMember.AddBoat(boat); Save(); }