Supermarket.Supermarket.RandomProduct C# (CSharp) Méthode

RandomProduct() public méthode

Gets a random product with a random quantity from the supermarket catalogue
public RandomProduct ( ) : Product
Résultat Product
        public Product RandomProduct()
        {
            // Random product
            int index = Random.Range(0, catalogue.Count);
            Product product = catalogue.ElementAt(index).Value;
            Product productToGive = product.Split();                // New instance, same stats

            // Random quantity
            productToGive.Quantity = Random.Range(1, 50);
            return productToGive;
        }