-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram (3).cs
50 lines (50 loc) · 1.1 KB
/
program (3).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
public class StringTooShortException : Exception
{
public StringTooShortException(string message) : base(message)
{
}
}
class FileEdit
{
public FileEdit(string fileName)
{
this.writer = new StreamWriter(fileName);
}
private StreamWriter writer;
public void Close()
{
writer.Close();
}
public void Input(string inputString)
{
if (inputString.Length < 3)
{
throw new StringTooShortException("Строка слишком мала");
}
else
{
this.writer.Write(inputString[2]);
}
}
}
public class Program
{
static void Main(string[] args)
{
string fileName = Console.ReadLine();
string inputString = Console.ReadLine();
FileEdit FileEd = new FileEdit(fileName);
try
{
FileEd.Input(inputString);
}
catch
{
Console.WriteLine("Строка слишком мала");
}
finally
{
FileEd.Close();
}
}
}