-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputTester.cs
More file actions
35 lines (25 loc) · 756 Bytes
/
InputTester.cs
File metadata and controls
35 lines (25 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.Text;
namespace ChessBoard
{
/// <summary>
/// This static class has one method that tests the user input via console. It makes sure that the user ONLY enters integer values
/// for square size and board size. If not then it prompts the user to do so!
/// </summary>
public static class InputTester
{
public static int TestInput(string s)
{
if (int.TryParse(s, out int inputInteger) && inputInteger > 0)
{
return inputInteger;
}
else
{
Console.WriteLine("Please enter a positive integer!");
return 0;
}
}
}
}