dimanche 9 février 2020

C# Im trying to randomly select one of the customer items from the list but it is giving me this output. any insight will be accepted

m trying to randomly select one of the customer items from the list but it is giving me this output. I am not sure what else to do to actually print out the info within the list. any insight will be accepted

I have this as my customer class

namespace PizzaParlor
{

class Customer
{
    private string name;
    private int flavor;
    private int price;
    private int quality;
    private int speed;
    private int accessibility;
    private int brand;
    private int convenience;
    private int variety;


    public Customer(string name, int flavor, int price, int quality, int speed, int accessibility, int brand, int convenience, int variety)
    {
        this.name = name;
        this.flavor = flavor;
        this.price = price;
        this.quality = quality;
        this.speed = speed;
        this.accessibility = accessibility;
        this.brand = brand;
        this.convenience = convenience;
        this.variety = variety;
    }

    // Name, Speed, Quality, Variety, Conveninnve, Accesiility, price, brand, flavor
    public string Name
    {
        get { return name; }
        set { name = value; }
    }

    public int Speed
    {
        get { return speed; }
        set { speed = value; }
    }

    public int Quality
    {
        get { return quality; }
        set { quality = value; }
    }

    public int Variety
    {
        get { return variety; }
        set { variety = value; }
    }

    public int Convenience
    {
        get { return convenience; }
        set { convenience = value; }
    }

    public int Acessibility
    {
        get { return accessibility; }
        set { accessibility = value; }
    }

    public int Price
    {
        get { return price; }
        set { price = value; }
    }

    public int Brand
    {
        get { return brand; }
        set { brand = value; }
    }

    public int Flavor
    {
        get { return flavor; }
        set { flavor = value; }
    }
}

}

and this as my main class that I set up to work with the customer class.

namespace PizzaParlor {

class Program
{

    static void Main(string[] args)
    {
        var random = new Random();

        List<Customer> CustomerList = new List<Customer>();

        CustomerList.Add(new Customer("bill", 20,15,10,5,10,20,5,15));
        CustomerList.Add(new Customer("kevin", 15, 10, 5, 20, 15, 15, 0, 20));
        CustomerList.Add(new Customer("clair", 8,25,2,25,5,15,0,20));
        CustomerList.Add(new Customer("jim", 15,20,10,15,0,40,0,0));
        CustomerList.Add(new Customer("rachel", 20,15,10,5,10,30,0,10));
        CustomerList.Add(new Customer("jeff", 30,20,5,5,10,10,0,20));
        CustomerList.Add(new Customer("Mike", 21,23,0,10,14,16,0,16));
        CustomerList.Add(new Customer("john", 25,15,10,10,10,5,5,20));



        int index = random.Next(CustomerList.Count);

        Console.WriteLine(CustomerList[index]);

I know that the random.Next(CustomerList.Count) will randomly a select from the list but I don't know why it is giving me this output.

output picture




Aucun commentaire:

Enregistrer un commentaire