diff --git a/DigitalCathedral.Task1/DigitalCathedral.Task1.csproj b/DigitalCathedral.Task1/DigitalCathedral.Task1.csproj
new file mode 100644
index 0000000..172aea0
--- /dev/null
+++ b/DigitalCathedral.Task1/DigitalCathedral.Task1.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/DigitalCathedral.Task1/Program.cs b/DigitalCathedral.Task1/Program.cs
new file mode 100644
index 0000000..2fec469
--- /dev/null
+++ b/DigitalCathedral.Task1/Program.cs
@@ -0,0 +1,25 @@
+// See https://aka.ms/new-console-template for more information
+
+using DigitalCathedral.Task1;
+
+try
+{
+ Student s1 = new Student("", "", "", "", "", 3);
+ Student s2 = new Student("", "", "", "", "", 3);
+ Console.WriteLine(s1.Equals(s2));
+ Student st = new Student("Ivanov", "Ivan", "Ivanovich", "M1O-301B-21", "1234-123-12", 3);
+
+ Console.WriteLine("No exceptions were thrown");
+}
+catch (ArgumentNullException ex)
+{
+ //
+ Console.WriteLine(ex.Message);
+}
+catch (ArgumentException ex)
+{
+ //
+ Console.WriteLine(ex.Message);
+}
+
+Console.WriteLine("after try/catch...");
\ No newline at end of file
diff --git a/DigitalCathedral/Student.cs b/DigitalCathedral.Task1/Student.cs
similarity index 77%
rename from DigitalCathedral/Student.cs
rename to DigitalCathedral.Task1/Student.cs
index e1fc681..4513c86 100644
--- a/DigitalCathedral/Student.cs
+++ b/DigitalCathedral.Task1/Student.cs
@@ -1,4 +1,4 @@
-namespace DigitalCathedral;
+namespace DigitalCathedral.Task1;
public sealed class Student:
IEquatable
@@ -8,7 +8,7 @@ public sealed class Student:
private readonly string _name;
private readonly string _patronymic;
private readonly string _group;
- private readonly string _zachetka;
+ private readonly string _recordBookId;
private readonly int _course;
public Student(
@@ -16,7 +16,7 @@ public Student(
string? name,
string? patronymic,
string? group,
- string? zachetka,
+ string? recordBookId,
int course)
{
if (surname is null)
@@ -28,7 +28,7 @@ public Student(
_name = name ?? throw new ArgumentNullException(nameof(name));
_patronymic = patronymic ?? throw new ArgumentNullException(nameof(patronymic));
_group = group ?? throw new ArgumentNullException(nameof(group));
- _zachetka = zachetka ?? throw new ArgumentNullException(nameof(zachetka));
+ _recordBookId = recordBookId ?? throw new ArgumentNullException(nameof(recordBookId));
// if (!(course >= 1 && course <= 4))
if (course < 1 || course > 4)
{
@@ -49,15 +49,15 @@ public Student(
public string Group =>
_group;
- public string Zachetka =>
- _zachetka;
+ public string RecordBookId =>
+ _recordBookId;
public int Course =>
_course;
public override string ToString()
{
- return "";
+ return $"Surname = \"{Surname}\", Name = \"{Name}\", Patronymic = \"{Patronymic}\", Group = \"{Group}\", Record book id = \"{RecordBookId}\", Course = {Course}";
}
public override int GetHashCode()
@@ -67,7 +67,7 @@ public override int GetHashCode()
result.Add(_name);
result.Add(_patronymic);
result.Add(_group);
- result.Add(_zachetka);
+ result.Add(_recordBookId);
result.Add(_course);
return result.ToHashCode();
}
@@ -100,7 +100,7 @@ public bool Equals(
_name.Equals(student._name) &&
_patronymic.Equals(student._patronymic) &&
_group.Equals(student._group) &&
- _zachetka.Equals(student._zachetka) &&
+ _recordBookId.Equals(student._recordBookId) &&
_course.Equals(student._course);
}
diff --git a/DigitalCathedral/CombinatoricsExtensions.cs b/DigitalCathedral.Task2/CombinatoricsExtensions.cs
similarity index 94%
rename from DigitalCathedral/CombinatoricsExtensions.cs
rename to DigitalCathedral.Task2/CombinatoricsExtensions.cs
index c0ad982..89be572 100644
--- a/DigitalCathedral/CombinatoricsExtensions.cs
+++ b/DigitalCathedral.Task2/CombinatoricsExtensions.cs
@@ -1,4 +1,4 @@
-namespace DigitalCathedral;
+namespace DigitalCathedral.Task2;
public static class CombinatoricsExtensions
{
diff --git a/DigitalCathedral.Task2/DigitalCathedral.Task2.csproj b/DigitalCathedral.Task2/DigitalCathedral.Task2.csproj
new file mode 100644
index 0000000..172aea0
--- /dev/null
+++ b/DigitalCathedral.Task2/DigitalCathedral.Task2.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/DigitalCathedral/IntEqualityComparer.cs b/DigitalCathedral.Task2/IntEqualityComparer.cs
similarity index 86%
rename from DigitalCathedral/IntEqualityComparer.cs
rename to DigitalCathedral.Task2/IntEqualityComparer.cs
index d22c2fa..6d38b80 100644
--- a/DigitalCathedral/IntEqualityComparer.cs
+++ b/DigitalCathedral.Task2/IntEqualityComparer.cs
@@ -1,7 +1,8 @@
-namespace DigitalCathedral;
+namespace DigitalCathedral.Task2;
public sealed class IntEqualityComparer : IEqualityComparer
{
+
private const int EventIntHashCode = 0;
public bool Equals(
@@ -25,4 +26,5 @@ public int GetHashCode(
}
return obj.GetHashCode();
}
+
}
\ No newline at end of file
diff --git a/DigitalCathedral.Task2/Program.cs b/DigitalCathedral.Task2/Program.cs
new file mode 100644
index 0000000..7179536
--- /dev/null
+++ b/DigitalCathedral.Task2/Program.cs
@@ -0,0 +1,12 @@
+using DigitalCathedral.Task2;
+
+try
+{
+ IEqualityComparer equalityComparer = new IntEqualityComparer();
+ var values = new int [] { 1, 2, 3, 4, 5 };
+ values.GetCombinations(3, equalityComparer);
+}
+catch (ArgumentException ex)
+{
+ Console.WriteLine(ex.Message);
+}
\ No newline at end of file
diff --git a/DigitalCathedral.sln b/DigitalCathedral.sln
index f890101..50bacb6 100644
--- a/DigitalCathedral.sln
+++ b/DigitalCathedral.sln
@@ -2,6 +2,12 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalCathedral", "DigitalCathedral\DigitalCathedral.csproj", "{1D8020D4-5048-4BBB-A779-44E7C3AD43CB}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tasks", "Tasks", "{8193D3C5-610D-4FEF-B2C2-8E41D6594161}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalCathedral.Task1", "DigitalCathedral.Task1\DigitalCathedral.Task1.csproj", "{8022E880-A4E4-441B-8D90-195C4382F1C8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalCathedral.Task2", "DigitalCathedral.Task2\DigitalCathedral.Task2.csproj", "{26461CE6-A23D-4B47-B9B4-C1354CBBC946}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -12,5 +18,17 @@ Global
{1D8020D4-5048-4BBB-A779-44E7C3AD43CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D8020D4-5048-4BBB-A779-44E7C3AD43CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D8020D4-5048-4BBB-A779-44E7C3AD43CB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8022E880-A4E4-441B-8D90-195C4382F1C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8022E880-A4E4-441B-8D90-195C4382F1C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8022E880-A4E4-441B-8D90-195C4382F1C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8022E880-A4E4-441B-8D90-195C4382F1C8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {26461CE6-A23D-4B47-B9B4-C1354CBBC946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {26461CE6-A23D-4B47-B9B4-C1354CBBC946}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {26461CE6-A23D-4B47-B9B4-C1354CBBC946}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {26461CE6-A23D-4B47-B9B4-C1354CBBC946}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {8022E880-A4E4-441B-8D90-195C4382F1C8} = {8193D3C5-610D-4FEF-B2C2-8E41D6594161}
+ {26461CE6-A23D-4B47-B9B4-C1354CBBC946} = {8193D3C5-610D-4FEF-B2C2-8E41D6594161}
EndGlobalSection
EndGlobal
diff --git a/DigitalCathedral/IEnumerableImpl.cs b/DigitalCathedral/IEnumerableImpl.cs
new file mode 100644
index 0000000..f361da0
--- /dev/null
+++ b/DigitalCathedral/IEnumerableImpl.cs
@@ -0,0 +1,24 @@
+using System.Collections;
+
+namespace DigitalCathedral;
+
+public class IEnumerableImpl:
+ IEnumerable
+{
+
+ private readonly int[] _values = new[] { 1, 2, 3, 4, 5 };
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return _values.GetEnumerator();
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ for (var i = 0; i < _values.Length; i++)
+ {
+ yield return _values[i];
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/DigitalCathedral/Program.cs b/DigitalCathedral/Program.cs
index 41e300b..79c588e 100644
--- a/DigitalCathedral/Program.cs
+++ b/DigitalCathedral/Program.cs
@@ -70,6 +70,7 @@
// { +k, x > y
// IComparable, IComparable, IComparer
+using System.Collections;
using DigitalCathedral;
//
// int value = 11;
@@ -266,27 +267,7 @@
// // TODO: work with value
// }
//
-// Student s1 = new Student("", "", "", "", "", 3);
-// Student s2 = new Student("", "", "", "", "", 3);
-// Console.WriteLine(s1.Equals(s2));
-//
-// try
-// {
-// Student st = new Student("Ivanov", "Ivan", "Ivanovich", "M1O-301B-21", "1234-123-12", 3);
-//
-// Console.WriteLine("No exceptions were thrown");
-// }
-// catch (ArgumentNullException ex)
-// {
-// //
-// Console.WriteLine(ex.Message);
-// }
-// catch (ArgumentException ex)
-// {
-// //
-// Console.WriteLine(ex.Message);
-// }
-// Console.WriteLine("after try/catch...");
+
//
// var fraction = new Fraction(2, 5);
// var fraction2 = new Fraction(1, 7);
@@ -295,14 +276,24 @@
// var multiplicationResult = Fraction.Multiplication(fraction, fraction2);
//
// Console.WriteLine(fraction.CompareTo(fraction2));
+{
+ int value = 10;
+ object o = (object) value;
+ int value1 = (int) o;
+ Console.WriteLine(value1);
+}
-try
+var impl = new IEnumerableImpl();
+var iterator = ((IEnumerable)impl).GetEnumerator();
+while (iterator.MoveNext())
{
- IEqualityComparer equalityComparer = new IntEqualityComparer();
- var values = Enumerable.Range(1, 10).ToArray();
- values.GetCombinations(3, equalityComparer);
+ Console.WriteLine((int)iterator.Current);
}
-catch (ArgumentException ex)
+
+foreach (var value in impl)
{
- Console.WriteLine(ex.Message);
-}
\ No newline at end of file
+ Console.WriteLine(value);
+}
+
+//IComparer
+//IEqualityComparer;
\ No newline at end of file