// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- public void PickElements() { int currentRandom; bool ElementListempty = !ElementList.Any(); bool NumberListempty = !NumberList.Any(); //Checks if both elements assigned with boolean are empty or not if (ElementListempty != true || NumberListempty != true) { //ElementList.Clear() = Empty ElementList.Clear(); NumberList.Clear(); m_build();// will fill the numberList for (int j = 1; j <= ElementNumber; j++) { currentRandom = m_random.Next(1, NumberList.Count); NumberList.Remove(currentRandom); ElementList.Add(currentRandom); } ElementList.Sort();//Sort } }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- /// <summary> /// pickElements this method generate random numbers. /// after generating remove from numberList and add to elementlist /// </summary> public void PickElements() { int currentRandom; bool ElementListempty = !ElementList.Any(); bool NumberListempty = !NumberList.Any(); //checking if the elementList and NumberList are empty or not if (ElementListempty != true || NumberListempty != true) { //if the lists contain some values the clear is used to make them empty ElementList.Clear(); NumberList.Clear(); m_build();// will fill the numberList for (int j = 1; j <= ElementNumber; j++) { currentRandom = m_random.Next(1, NumberList.Count); NumberList.Remove(currentRandom); ElementList.Add(currentRandom); } ElementList.Sort();//sorting the list } }