예제 #1
0
 //Calculate Loyal statistic
 public void CalculateLoyalStatistic(ulong loyalTicketsCount)
 {
     this.LoyalStatistic = new LoyalStatistic()
     {
         LoyalCount        = 1 + LoyalStatistic.LoyalCount,
         LoyalTicketsCount = loyalTicketsCount + LoyalStatistic.LoyalTicketsCount
     };
 }
예제 #2
0
        public void GetInformation()
        {
            try
            {
                StreamReader fileReader = new StreamReader("DataFiles/AccountantDataBase.txt");
                if (fileReader != null)
                {
                    using (fileReader)
                    {
                        List <Ticket> tickets = new List <Ticket>();
                        //Total Statistic
                        string[] firstRowElements = fileReader.ReadLine().Split(new char[] { charDevidors[0] }, StringSplitOptions.RemoveEmptyEntries);
                        TotalStatistic = new TotalStatistic(double.Parse(firstRowElements[0]), firstRowElements[1], firstRowElements[2]);
                        //Discounted Statistic
                        DiscountedStatistic = new DiscountStatistic(int.Parse(fileReader.ReadLine()));
                        //Loyal Statistic
                        string[] thirdRowElements = fileReader.ReadLine().Split(new char[] { charDevidors[0] }, StringSplitOptions.RemoveEmptyEntries);
                        LoyalStatistic = new LoyalStatistic
                        {
                            LoyalCount        = ulong.Parse(thirdRowElements[0]),
                            LoyalTicketsCount = ulong.Parse(thirdRowElements[1])
                        };

                        //Tickets
                        string[] restFileContent = fileReader.ReadToEnd().Split(new char[] { charDevidors[1], charDevidors[2] }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (var currentTicket in restFileContent)
                        {
                            string[] ticketElements = currentTicket.Split(new char[] { charDevidors[0] }, StringSplitOptions.RemoveEmptyEntries);
                            tickets.Add(new Ticket(int.Parse(ticketElements[0]), ticketElements[1], ticketElements[2], double.Parse(ticketElements[3])));
                        }
                        SoldTickets = tickets;
                    }
                }
            }
            catch (Exception)
            {
                this.TotalStatistic      = new TotalStatistic(0, "", "");
                this.DiscountedStatistic = new DiscountStatistic(0);
                this.LoyalStatistic      = new LoyalStatistic()
                {
                    LoyalCount        = 0,
                    LoyalTicketsCount = 0
                };
            }
        }