Beispiel #1
0
        private List <Extra> extras = new List <Extra>(); //Holds references to all the extras associated with the booking

        //contructer used to create new bookings
        public Booking()
        {
            //Booking reference number automatically generated using the BookingRefGenerator class
            BookingRefGenerator bookingRefGen = BookingRefGenerator.Instance();

            referenceNumber = bookingRefGen.GetReference();
            datePattern     = "yyyy-MM-dd"; //pattern for dates used in DateTime fields
        }
        private int refNumber;                       //holds the current bookingRefNumber


        //Method always return the same instance of the class
        public static BookingRefGenerator Instance()
        {
            //Create new instance if it hasnt been created previously (if it is null)
            if (instance == null)
            {
                instance = new BookingRefGenerator();                      //Create new instance
                CSVHandler CSVFile = CSVHandler.Instance();                //Get a reference to the CSVFacade
                instance.refNumber = CSVFile.GetCurrentBookingRefNumber(); //Get last reference number given to a booking 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)
        }