Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Console.Write("Enter weight of parcel: ");
- string input = Console.ReadLine();
- class Program
- {
- private static int _depth = 0;
- private static int _height = 0;
- private static int _weight = 0;
- private static int _width = 0;
- private static bool _isInvalidInput = true;
- static void Main(string[] args)
- {
- GetWeightInput();
- GetHeightInput();
- GetWidthInput();
- GetDepthInput();
- Console.ReadLine();
- }
- private static void GetWeightInput()
- {
- while(_isInvalidInput)
- {
- Console.Write("Enter weight of parcel: ");
- string input = Console.ReadLine();
- #region User Weight Input Validation
- if (int.TryParse(input, out _weight))
- {
- _isInvalidInput = false;
- //TODO: Add More Validations of User Input
- }
- else
- {
- Console.WriteLine("***Only Integer Inputs Are Allowed***");
- _isInvalidInput = true;
- }
- #endregion User Weight Input Validation
- }
- _isInvalidInput = true;//reset value to true
- }
- private static void GetHeightInput()
- {
- while (_isInvalidInput)
- {
- Console.Write("Enter weight of parcel: ");
- string input = Console.ReadLine();
- #region User Weight Input Validation
- if (int.TryParse(input, out _height))
- {
- _isInvalidInput = false;
- //TODO: Add More Validations of User Input
- }
- else
- {
- Console.WriteLine("***Only Integer Inputs Are Allowed***");
- _isInvalidInput = true;
- }
- #endregion User Weight Input Validation
- }
- _isInvalidInput = true;//reset value to true
- }
- private static void GetWidthInput()
- {
- while (_isInvalidInput)
- {
- Console.Write("Enter weight of parcel: ");
- string input = Console.ReadLine();
- #region User Weight Input Validation
- if (int.TryParse(input, out _width))
- {
- _isInvalidInput = false;
- //TODO: Add More Validations of User Input
- }
- else
- {
- Console.WriteLine("***Only Integer Inputs Are Allowed***");
- _isInvalidInput = true;
- }
- #endregion User Weight Input Validation
- }
- _isInvalidInput = true;//reset value to true
- }
- private static void GetDepthInput()
- {
- while (_isInvalidInput)
- {
- Console.Write("Enter weight of parcel: ");
- string input = Console.ReadLine();
- #region User Weight Input Validation
- if (int.TryParse(input, out _width))
- {
- _isInvalidInput = false;
- //TODO: Add More Validations of User Input
- }
- else
- {
- Console.WriteLine("***Only Integer Inputs Are Allowed***");
- _isInvalidInput = true;
- }
- #endregion User Weight Input Validation
- }
- _isInvalidInput = true;//reset value to true
- }
- }
- static void Main(string[] args)
- {
- GetWeightInput();
- GetHeightInput();
- GetWidthInput();
- GetDepthInput();
- Console.ReadLine();
- }
- static void Main(string[] args)
- {
- var weight = AskInteger("Enter weight of parcel: ");
- var height = AskInteger("Enter height of parcel: ");
- var width = AskInteger("Enter width of parcel: ");
- var depth = AskInteger("Enter depth of parcel: ");
- Console.WriteLine("press any key to terminate the application..");
- Console.ReadKey(true);
- }
- static void Main(string[] args)
- {
- var request = new Request();
- AskInteger(request, x => x.Weight);
- AskInteger(request, x => x.Height);
- AskInteger(request, x => x.Width);
- AskInteger(request, x => x.Depth);
- Console.WriteLine("press any key to terminate the application..");
- Console.ReadKey(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement