public static int GetPlantChoice(MyPlants plantBox) { int i = 0; foreach (Plant myPlant in plantBox.GetAllPlants()) { Console.WriteLine($"[{i++}]{myPlant.PlantName}"); } return(GetInt("Please Enter the ID of the Plant")); }
static void Main(string[] args) { SqlConnection gardenDB = new SqlConnection(@"Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=C:\USERS\RINZLER\DOCUMENTS\ACADEMY\CODE\GARDENBOX\GARDENBOX.MDF;Integrated Security=True"); gardenDB.Open(); MyPlants plantbed = GetPlantBed(); GardenBoxDB plantDATA = new GardenBoxDB(gardenDB); plantbed.AddPlantsToGardenBox(plantDATA.GetPlantList()); //add db to plantbed int plantchoice = GetPlantChoice(plantbed); Console.WriteLine($"You can plant {plantbed.CalculatePlanting(plantchoice)} {plantbed.GetAllPlants()[plantchoice]}"); Console.ReadLine(); gardenDB.Close(); }