Example #1
0
        //
        /// <summary>
        /// to find out which resident paid the least amount
        /// </summary>
        /// <param name="residentlist"></param>
        /// <param name="servicelist"></param>
        /// <returns></returns>
        public static Resident LeastPaid(ResidentList residentlist, ServiceList servicelist)
        {
            residentlist.Beginning();
            Resident temp      = residentlist.Get();
            Resident resident  = new Resident();
            Resident residents = new Resident();
            double   temp1     = Calcs.HowMuchPaid(temp, servicelist);
            double   temp2     = 0;

            if (residentlist.getCount() == 1)
            {
                residents = new Resident(residentlist.Get().Name, residentlist.Get().Surname, servicelist.Get().Title, residentlist.Get().Month);
                return(residents);
            }

            for (residentlist.Beginning(); residentlist.Exist(); residentlist.Next())
            {
                temp2 = Calcs.HowMuchPaid(residentlist.Get(), servicelist);
                if (temp2 < temp1)
                {
                    resident = new Resident(residentlist.Get().Name, residentlist.Get().Surname, servicelist.Get().Title, residentlist.Get().Month);
                    temp1    = temp2;
                }
            }
            return(resident);
        }
Example #2
0
        /// <summary>
        /// method to find the average price of the service paid by the residents
        /// </summary>
        /// <param name="residentlist"></param>
        /// <param name="servicelist"></param>
        /// <returns></returns>
        public static double AveragePrice(ResidentList residentlist, ServiceList servicelist)
        {
            double average = 0;
            double sum     = Calcs.TotalAmountPaid(residentlist, servicelist);

            average = sum / residentlist.getCount();

            return(average);
        }
Example #3
0
        /// <summary>
        /// to find the list of the residents who paid less than average for the services
        /// </summary>
        /// <param name="residentlist"></param>
        /// <param name="servicelist"></param>
        /// <returns></returns>
        public static ResidentList PaidLessThanAvg(ResidentList residentlist, ServiceList servicelist)
        {
            ResidentList residentaverage = new ResidentList();

            residentlist.Beginning();
            double avg = Calcs.AveragePrice(residentlist, servicelist);

            residentlist.Beginning();

            for (residentlist.Beginning(); residentlist.Exist(); residentlist.Next())
            {
                if (Calcs.HowMuchPaid(residentlist.Get(), servicelist) < avg)
                {
                    residentaverage.PutData(residentlist.Get());
                }
            }
            return(residentaverage);
        }