-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.cs
97 lines (90 loc) · 2.35 KB
/
Student.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
using System;
using System.Collections.Generic;
using System.Text;
namespace Static_keyword__Extension_Methods
{
internal class Student
{
private static string _fullName;
private static string _groupNo;
private int _age;
public string FullName
{
get
{
return _fullName;
}
set
{
if (CheckFullname(value))
{
_fullName = value;
}
else
{
Console.WriteLine("Telebe Ad Sehvdir");
}
}
}
public string GroupNo
{
get
{
return _groupNo;
}
set {
if (CheckGroupNo(value))
{
_groupNo = value;
Console.WriteLine("Ad set olundu");
}
else
{
Console.WriteLine("Ad Sehvdir");
}
}
}
public int Age { get; set; }
public static bool CheckGroupNo(string value)
{
if (value.Length == 4)
{
int count = 0;
for (int i = 0; value.Length > i; i++)
{
if (char.IsUpper(value[i]) && i == 0)
{
count++;
}
else if (char.IsDigit(value[i]))
{
count++;
}
}
return count == 4 ? true : false;
}
return false;
}
public static bool CheckFullname(string value)
{
for (int i = 0; value.Length > i; i++)
{
int count = 0;
if (char.IsUpper(value[i]) && i == 0)
{
count++;
}
else if (char.IsWhiteSpace(value[i]) && value[i + 1] != ' ')
{
count++;
if (char.IsUpper(value[i + 1]))
{
count++;
}
}
return count == 3 ? true : false;
}
return false;
}
}
}