/// <summary> /// Finding result of problem solving /// </summary> /// <returns>Result</returns> private double findeResult() { //Result double result = 0.0; //If we have any pancakes if (PancakeList.Count > 0) { //Pancake with the biggest radius Pancake max = PancakeList[0]; //In list of pancake foreach (Pancake p in PancakeList) { //Add outer sqear result += 2 * Math.PI * p.R * p.H; //Define if radius of current pancake is bigger than preveous if (p.R > max.R) { max = p; } } //Add top sqear of the biggest radius pancake result += Math.PI * Math.Pow(max.R, 2); } return(result); }
/// <summary> /// Finding max-radius pancake /// </summary> /// <param name="pList"></param> /// <returns></returns> static Pancake MaxRadius(List <Pancake> pList) { Pancake max = new Pancake(); foreach (Pancake p in pList) { if (p.R > max.R) { max = p; } } return(max); }
/// <summary> /// Comperer of pancakes acording to their radius /// </summary> /// <param name="p1">First pancake</param> /// <param name="p2">Seckond pancake</param> /// <returns>If first pancake is bigger, equel or the same with seckond</returns> static int RadiusCompear(Pancake p1, Pancake p2) { //If radius of the first pancake is bigger if (p1.R > p2.R) { return(1); } //If radius of the seckond pancake is bigger else if (p2.R > p2.R) { return(-1); } //If pancakes are equel else { return(0); } }
/// <summary> /// Comperer of pancakes acording to their outer sqear /// </summary> /// <param name="p1">First pancake</param> /// <param name="p2">Seckond pancake</param> /// <returns>If first pancake is bigger, equel or the same with seckond</returns> static int OutSqrCompear(Pancake p1, Pancake p2) { //If outer sqear of the first pancake is bigger if (p1.H * p1.R > p2.H * p2.R) { return(1); } //If outer sqear of the seckond pancake is bigger else if (p2.H * p2.R > p1.H * p2.R) { return(-1); } //If pancakes are equel else { return(0); } }