-
Notifications
You must be signed in to change notification settings - Fork 4
/
Program.cs
102 lines (75 loc) · 3.37 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Checkbox
{
internal class Program
{
public static void Main(string[] args)
{
// Console settings
Console.InputEncoding = Console.OutputEncoding = Encoding.UTF8;
Console.CursorVisible = false;
// string input array
string[] options = {"first option", "second option", "third option", "fourth option", "fifth option"};
////////////////////////////////////////////////////////////
//// EXAMPLE: SELECT MAX ONE OPTION; SELECTION REQUIRED ////
////////////////////////////////////////////////////////////
// class init
Checkbox c1 = new Checkbox("Select one of the following options", options);
var res1 = c1.Select();
Console.Clear();
// example usage: print selected indices and options
foreach (var checkboxReturn in res1)
{
Console.WriteLine(checkboxReturn.Index);
Console.WriteLine(checkboxReturn.Option);
}
Console.ReadKey(true);
//////////////////////////////////////////////////////////////
//// EXAMPLE: SELECT MULTIPLE OPTIONS; SELECTION REQUIRED ////
//////////////////////////////////////////////////////////////
// class init
Checkbox c2 = new Checkbox("Select at least one of the following options", true, true, options);
var res2 = c2.Select();
Console.Clear();
// example usage: print selected indices and options
foreach (var checkboxReturn in res2)
{
Console.WriteLine(checkboxReturn.Index);
Console.WriteLine(checkboxReturn.Option);
}
Console.ReadKey(true);
///////////////////////////////////////////////////////////////
//// EXAMPLE: SELECT MAX ONE OPTION; NO SELECTION REQUIRED ////
///////////////////////////////////////////////////////////////
// class init
Checkbox c3 = new Checkbox("Select one of the following options (optional)", false, false, options);
var res3 = c3.Select();
Console.Clear();
// example usage: print selected indices and options
foreach (var checkboxReturn in res3)
{
Console.WriteLine(checkboxReturn.Index);
Console.WriteLine(checkboxReturn.Option);
}
Console.ReadKey(true);
/////////////////////////////////////////////////////////////////
//// EXAMPLE: SELECT MULTIPLE OPTIONS; NO SELECTION REQUIRED ////
/////////////////////////////////////////////////////////////////
// class init
Checkbox c4 = new Checkbox("Select at least one of the following options (optional)", true, false, options);
var res4 = c4.Select();
Console.Clear();
// example usage: print selected indices and options
foreach (var checkboxReturn in res4)
{
Console.WriteLine(checkboxReturn.Index);
Console.WriteLine(checkboxReturn.Option);
}
Console.ReadKey(true);
}
}
}