/* * Determines what calculation is being invoked (surface area or volume, does not matter what object type) * This is essentially a helper function for GetSurfaceArea or GetVolume * Does not do calculation of its own; calls for a calculation to be made * Returns requested calculation */ private void CallOutput(string input, CalculatorUI calc) { if (input == "1" || input == "2" || input == "3") { string surf_area = Convert.ToString(calc.GetSurfaceArea()); //Invokes GetSurfaceArea to calculate the surface area of object specified by user Console.WriteLine("Surface Area : " + surf_area); } else if (input == "4" || input == "5" || input == "6") { string volume = Convert.ToString(calc.GetVolume()); //Invokes GetVolume to calculate the volume of object specified by user Console.WriteLine("Volume : " + volume); } }
/* * Creates a new object based on object selected and input from PrintMainUI * Invokes CallOutput to continue user specified calculation */ private void SelectNewObject(string input) { if (input == "1" || input == "4") //If 1 or 4, invoke a new sphere object { CalculatorUI new_sphere = Sphere.CreateNewSphere(); //Create new object CallOutput(input, new_sphere); //Return input and object in CallOutput function for calculation } else if (input == "2" || input == "5") //If 2 or 5, invokes a new rectangular prism object { CalculatorUI new_rect_prism = RectangularPrism.CreateNewRectangularPrism(); CallOutput(input, new_rect_prism); } else if (input == "3" || input == "6") //If 3 or 6, invoke a new cone object { CalculatorUI new_cone = Cone.CreateNewCone(); CallOutput(input, new_cone); } }