Created
October 13, 2016 18:51
-
-
Save NamXH/60de920892a6bb75cfe4ffc8f1bbe031 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class CartonConstants | |
| { | |
| public static readonly int LengthInInch = 18; | |
| public static readonly int WidthInInch = 18; | |
| public static readonly int HeightInInch = 8; | |
| } | |
| public class Solution | |
| { | |
| public bool ValidateLength(string lengthStr) | |
| { | |
| var length = 0f; | |
| if (float.TryParse(lengthStr, out length) && length > 0) | |
| { | |
| return true; | |
| } | |
| else | |
| { | |
| return false; | |
| } | |
| } | |
| public bool ValidateInput(string lengthStr, string widthStr, string heightStr) | |
| { | |
| if (ValidateLength(lengthStr) && ValidateLength(widthStr) && ValidateLength(heightStr)) | |
| { | |
| return true; | |
| } | |
| else | |
| { | |
| return false; | |
| } | |
| } | |
| public int GetNumberOfCartons(float lengthInFt, float widthInFt, float heightInFt) | |
| { | |
| var FtToInch = 12; | |
| return (int)(lengthInFt * FtToInch / CartonConstants.LengthInInch) * (int)(widthInFt * FtToInch / CartonConstants.WidthInInch) * (int)(heightInFt * FtToInch / CartonConstants.HeightInInch); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment