Example #1
0
        private List <Booking> costumerBookings; //hold a list of references to all the bookings of the customer

        //Constructer used to create new Customers
        public Costumer()
        {
            CostumerRefGenerator costRefGen = CostumerRefGenerator.Instance();

            referenceNumber  = costRefGen.GetReference(); //use the CostumerRefGenerator class to generate the right reference number for the booking
            costumerBookings = new List <Booking>();      //Creates an empty list of bookings
        }
        private int refNumber;                        //holds the current CustomerRefNumber

        //Method always return the same instance of the class
        public static CostumerRefGenerator Instance()
        {
            //Create new instance if it hasnt been created previously (if it is null)
            if (instance == null)
            {
                instance = new CostumerRefGenerator();                      //Create new instance
                CSVHandler CSVFile = CSVHandler.Instance();                 //Get a reference to the CSVFacade
                instance.refNumber = CSVFile.GetCurrentCostumerRefNumber(); //Get last reference number given to a customer from the records in the CSV and assign the value to the reference number of this class
            }
            return(instance);                                               //Return the instance of the class (always the same one)
        }