コード例 #1
0
 public void addPerformance(Performance perf)    //add performance parameter to our list
 {
     if (perf.getID() == 0)
     {
         perf.setID(generateNewPerfID());
     }
     performances.Add(perf);
 }
コード例 #2
0
        void addCustomers(Theatre pTheatre, int customersCount)
        {
            string[]           firstNames = { "Adam", "Alan", "Amanda", "Beevis", "Charles", "Claire", "Dale", "Dane", "Erik", "Emma", "Fred", "Georgia", "Harry", "Hannah", "Sara", "Julie", "Ashley", "Peter", "Rick", "Andrew", "Steven", "Paul", "Jack", "Clare", "Sarah", "Rebekka" };
            string[]           lastNames  = { "Evans", /*Ayy*/ "Martin", "Powell", "Kennedy", "Formby", "King", "Platt", "Reader", "Larne", "Smith", "Butterworth", "Schmidt", "LeBlanc", "Latham", "Wearing", "Webster", "Duffy", "Dole", "Murray", "Jackson", "Parker" };
            string[]           roadNames  = { "Row", "Street", "Lane", "Cross", "Point", "Road", "Walk", "Hill", "Grange", "Way", "Square", "End", "Boulevard", "Crossing" };
            string[]           postcodes  = { "DL7 8GF", "NN2 7TA",  "ME17 2JE", "G72 8BU",  "SR1 1RZ", "RG45 6PL", "SN16 9RG", "WV3 7EE",  "M23 0QN",  "DT11 0JG", "WR9 7RZ",  "S73 0QG",  "LA1 4UE", "TA20 2QW", "BR6 9RL",
                                              "WF12 8HU",           "V35 0AR",  "KA11 4DD", "SR5 5TX",  "EN2 8QD", "S4 8DA",   "E14 4HD",  "NR17 1XR", "SN8 3HH",  "RH10 3UW", "WF9 4TR",  "LL21 9SR", "WS3 5EZ", "BT45 6HQ", "LS14 1JF","KW1 5QG",   "EH4 7HH",
                                              "WA1 3QH",            "SE2 9TQ",  "CR3 5JZ",  "UB1 2TZ",  "E17 5EP", "EH15 2LH", "CV32 7EP", "RH15 8HB", "YO26 8JF", "SY13 2DY", "PL10 1JB", "SO18 5FT", "ML8 4EW", "OX28 3JN", "NR27 0EL","KT12 3JQ",  "BT43 6LP",
                                              "GU35 0PX",           "IP30 0EN", "SL8 5EB",  "NR15 2TH", "PR8 6BF", "TS27 3HA", "TQ13 7DN", "PL14 9TP", "BT18 9FD", "SE6 1SA",  "TR16 6NQ", "BH20 6NF", "WD3 3FS", "NG12 2AW", "CM11 2ZU","PL27 6JG" };
            Random             rnd                    = new Random(DateTime.Now.Millisecond * 20 + DateTime.Now.Second);
            int                currentIndex           = 0;
            List <Performance> dateSortedPerformances = new List <Performance>();

            dateSortedPerformances = pTheatre.findPerformancesAfterDate(DateTime.Now);
            for (int i = 0; i < customersCount; i++)
            {
                string             name     = firstNames[rnd.Next(0, firstNames.Length)];
                string             lastname = lastNames[rnd.Next(0, lastNames.Length)];
                string             postCode = postcodes[rnd.Next(0, postcodes.Length)];
                string             address  = firstNames[rnd.Next(0, firstNames.Length)] + " " + roadNames[rnd.Next(0, roadNames.Length)];
                bool               gold     = Convert.ToBoolean(rnd.Next(0, 2));
                DateTime           goldDate = DateTime.Now;
                List <Reservation> resList  = new List <Reservation>();
                if (gold)
                {
                    int time = rnd.Next(0, 360);
                    goldDate = goldDate.AddDays(-time);
                }
                bool hasReservation = Convert.ToBoolean(rnd.Next(0, 2));
                if (hasReservation)
                {
nextPerformance:
                    if (currentIndex > dateSortedPerformances.Count)
                    {
                        break;
                    }
                    Performance resPerf     = dateSortedPerformances[currentIndex];
                    string      performance = resPerf.getID().ToString() + "-" + resPerf.getTitle();
                    List <Seat> reserved    = new List <Seat>();
                    if (resPerf.getScreen().getUpperRemaining() > 0)
                    {
                        reserved = resPerf.getEmptyUpperSeat(rnd.Next(0, 7));
                    }
                    else if (resPerf.getScreen().getDressRemaining() > 0)
                    {
                        reserved = resPerf.getEmptyDressSeat(rnd.Next(0, 7));
                    }
                    else if (resPerf.getScreen().getStallsRemaining() > 0)
                    {
                        reserved = resPerf.getEmptyStallsSeat(rnd.Next(0, 7));
                    }
                    else
                    {
                        currentIndex++;
                        goto nextPerformance;
                    }
                    bool     paid    = Convert.ToBoolean(rnd.Next(0, 2));
                    DateTime resDate = new DateTime();
                    if (paid)
                    {
                        resDate = DateTime.Now.AddDays(rnd.Next(-360, -1));
                    }
                    else
                    {
                        resDate = DateTime.Now.AddDays(rnd.Next(-6, 0));
                    }
                    Reservation res = new Reservation(performance, reserved, paid, resDate);
                    resList.Add(res);
                }
                pTheatre.addCustomer(new Customer(name, lastname, address, postCode, gold, goldDate, resList));
            }
        }