-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
47 lines (37 loc) · 1.22 KB
/
Program.cs
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
36
37
38
39
40
41
42
43
44
45
46
47
using System;
namespace net.iskai.tools.TelephoneNumbers
{
class Program
{
static void Main( string[] args )
{
var input = string.Empty;
do
{
Console.Write("Enter telephone number: ");
} while (string.IsNullOrEmpty(input = Console.ReadLine()));
// convert any chars in the name (that have number mappings)
// to a digit so that the user can enter, for example, TAXI
var translated = NumberPadTranslator.Translate( input );
var validator = new NorwegianNumberPlanValidator( );
var isMobile = validator.IsValid( translated , NumberPlanValidatorMask.Mobile );
var isFixed = validator.IsValid( translated , NumberPlanValidatorMask.Geographic);
var isPremium = validator.IsValid( translated , NumberPlanValidatorMask.NonGeographic );
WriteResult( "Mobile" , isMobile );
WriteResult( "Fixed" , isFixed );
WriteResult( "Premium" , isPremium );
#if DEBUG
Console.WriteLine("Press any key.");
Console.ReadKey(true);
#endif
}
static void WriteResult(string caption, bool result)
{
Console.Write( caption + "\t\t" );
Console.ForegroundColor = result ? ConsoleColor.Red : ConsoleColor.Green;
Console.WriteLine( result ? "Yes" : "No" );
Console.ResetColor( );
}
}
}