public static void ReadCards() { string queryString = "select card_id, card_title, st_title, cult_id, optimal, tolerance, limit_dev from cards natural join stages"; using (NpgsqlConnection connection = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString)) { NpgsqlCommand command = new NpgsqlCommand(queryString, connection); connection.Open(); NpgsqlDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { Card new_Card = new Card { Card_id = (int)reader[0], Title = reader[1].ToString(), Stage = reader[2].ToString(), Cult_id = (int)reader[3], Optimal = (float)reader[4], Tolerance = (float)reader[5], Limit_deviation = (float)reader[6] }; Plants.Where(p => (p.Cult_id == new_Card.Cult_id) && (p.Stage == new_Card.Stage)).First().Cards_of_plant.Add(new_Card); new_Card = null; } } finally { reader.Close(); } } }
private int GetAvailablePower() { int power = 0; power = Plants.Where(x => x.On).Count(); return(power); }
public void ShowByLocation(string theLocation) { var plantLocation = Plants.Where(p => p.LocatedPlanted == theLocation); Console.Clear(); Console.WriteLine($"Here are the plants in {theLocation}."); foreach (var plant in plantLocation) { Console.WriteLine($"Plant number {plant.Id} is {plant.Species}."); } }
public void NeedWater() { Console.Clear(); var notWateredToday = Plants.Where(p => DateTime.Compare(DateTime.Now, p.LastWateredDate) > p.WaterFrequency); foreach (var plant in notWateredToday) { Console.WriteLine($"{plant.Species} needs watered."); } // View all the plants that have not been watered today }
public void ThirstyPlants() { Console.Clear(); var notWateredToday = Plants.Where(p => p.LastWateredDate < DateTime.Today); Console.WriteLine("Here are the plants that need water."); foreach (var plant in notWateredToday) { Console.WriteLine($"Plant number {plant.Id} is {plant.Species} last watered on {plant.LastWateredDate} garden."); } // View all the plants that have not been watered today }
//Update erode when plant is added private void UpdateErodes(Plant plant) { var isAllErodesEmpties = true; //foreach plant with erosion foreach (var otherPlant in Plants.Where(x => x.Erosion.Size > 0))//TODO only plants not positionned ? { //Si plant placée est sur erode ou êrturb erode suppr erode plant.Erosion = new Erosion(plant, Garden); if (otherPlant.Erosion.Size > 0) { isAllErodesEmpties = false; } } IsAllErodesEmpties = isAllErodesEmpties; }
public void TogglePlant() { string name = ""; PowerPlant plant = null; do { Console.Clear(); Console.WriteLine("What is the name of the power plant you would like to toggle: "); name = Console.ReadLine(); } while (IsNameAvailable(Plants, name)); plant = Plants.Where(x => x.Name == name).First(); ToggleBuilding <PowerPlant>(plant); }