/// <summary> /// Each present requires the smallest perimeter of one face, plus the cubic volume of the present. /// </summary> /// <param name="present"></param> /// <returns></returns> private static int GetRibbonRequirements(Present present) { int ribbonLength = present.SmallestPerimeter(); int bowLength = present.Volume; int totalRibbon = ribbonLength + bowLength; Console.WriteLine( $"Present {present.Length}L x {present.Width}W x {present.Height}H requires {ribbonLength} ft ribbon + {bowLength} bow, total {totalRibbon}."); return totalRibbon; }
/// <summary> /// Get paper required for present. /// </summary> /// <param name="p">Present to wrap</param> /// <returns></returns> private static int GetPaperRequirements(Present p) { List<int> areas = GetSideAreas(p); int smallestArea = areas.Min(); int surfaceArea = 2 * areas.Sum(); int total = smallestArea + surfaceArea; Console.WriteLine( $"Surface area: {surfaceArea} with {smallestArea} slack. Total area of {total}."); return total; }
/// <summary> /// Get area of sides. /// </summary> /// <param name="p">Present to measure.</param> /// <returns></returns> private static List<int> GetSideAreas(Present p) { Console.Write($"Present is {p.Length} long, {p.Width} wide, {p.Height} high. "); return new List<int> {p.Length * p.Width, p.Width * p.Height, p.Length * p.Height}; }