Beispiel #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);
        }
Beispiel #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);
        }