diff --git a/.gitignore b/.gitignore index 94bc87c..2025441 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ # Mono auto generated files mono_crash.* +*/.DS_Store/ # Build results [Dd]ebug/ [Dd]ebugPublic/ diff --git a/20240921/ConsoleApp1.csproj b/20240921/ConsoleApp1.csproj new file mode 100644 index 0000000..0ade2bf --- /dev/null +++ b/20240921/ConsoleApp1.csproj @@ -0,0 +1,26 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + + + + + + + + + diff --git a/20240921/ConsoleApp1.sln b/20240921/ConsoleApp1.sln new file mode 100644 index 0000000..aec00fb --- /dev/null +++ b/20240921/ConsoleApp1.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1.csproj", "{0DA6D9D0-8B23-4547-9885-B579F859E55F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0DA6D9D0-8B23-4547-9885-B579F859E55F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0DA6D9D0-8B23-4547-9885-B579F859E55F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0DA6D9D0-8B23-4547-9885-B579F859E55F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0DA6D9D0-8B23-4547-9885-B579F859E55F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/20240921/Pi232._0920/Bus.cs b/20240921/Pi232._0920/Bus.cs new file mode 100644 index 0000000..d2174af --- /dev/null +++ b/20240921/Pi232._0920/Bus.cs @@ -0,0 +1,54 @@ +namespace Pi232._0920; + + +public class Transport +{ + /// + /// тип транспортного средства + /// + public ETransport Type { get; set; } +} +public class Bus: Transport +{ + #region Свойства + + /// + /// Номер маршрута + /// + public string RouteNum { get; set; } + + /// + /// Фамилия водителя + /// + public Driver CurrentDriver { get; set; } + + + #endregion + + #region конструкторы + + /// + /// .ctor + /// + /// + /// + public Bus(string routeNum, string driver): + this(routeNum, new Driver(driver)) + { + } + + public Bus(string routeNum, Driver driver) + { + this.Type = ETransport.Bus; + RouteNum = routeNum; + CurrentDriver = driver; + CurrentDriver.SetState(true); + } + + #endregion + + public override string ToString() + { + return $"{CurrentDriver.Fio} / {RouteNum}"; + } +} \ No newline at end of file diff --git a/20240921/Pi232._0920/Driver.cs b/20240921/Pi232._0920/Driver.cs new file mode 100644 index 0000000..dcb3e41 --- /dev/null +++ b/20240921/Pi232._0920/Driver.cs @@ -0,0 +1,83 @@ +namespace Pi232._0920; + +public class Driver +{ + #region Свойства + + public string Surname { get; set; } + public string Middlename { get; set; } + public string Firstname { get; set; } + + public EDriverState State { get; private set; } + public string Fio => h_GetFio(); + + #endregion + + #region конструкторы + + public Driver( + string surname, + string firstname) + { + Surname = surname; + Firstname = firstname; + Middlename = String.Empty; + } + + public Driver( + string surname, + string middlename, + string firstname) + { + Surname = surname; + Middlename = middlename; + Firstname = firstname; + } + + public Driver(string sFio) + { + string[] ar = sFio.Split(' ', 3, StringSplitOptions.RemoveEmptyEntries); + switch (ar.Length) + { + case (< 2): + { + string sFio2 = ""; + return; + } + case ((2)): + { + string sFio2 = ""; + Surname = ar[0]; + Firstname = ar[1]; + break; + } + default: + Surname = ar[0]; + Firstname = ar[1]; + Middlename = ar[2]; + break; + } + } + + #endregion + + private string h_GetFio() + { + return $"{Surname} {Firstname} {Middlename}"; + } + + public void SetState(bool bIsActive) + { + State = (bIsActive + ? EDriverState.Work + : EDriverState.Rest); + } + +} + +public enum EDriverState +{ + Unknown, + Work, + Rest +} \ No newline at end of file diff --git a/20240921/Pi232._0920/ETransport.cs b/20240921/Pi232._0920/ETransport.cs new file mode 100644 index 0000000..e9629a9 --- /dev/null +++ b/20240921/Pi232._0920/ETransport.cs @@ -0,0 +1,7 @@ +namespace Pi232._0920; + +public enum ETransport +{ + Unknown = 0, + Bus = 1 +} \ No newline at end of file diff --git a/20240921/Program.cs b/20240921/Program.cs new file mode 100644 index 0000000..fd71929 --- /dev/null +++ b/20240921/Program.cs @@ -0,0 +1,98 @@ +using Pi232._0920; + +namespace ConsoleApp1; + +class Program +{ + static void Main(string[] args) + { + // h_TestSep12(); + List arBus = h_GetBusList(); + foreach (Bus bus in arBus) + { + Console.WriteLine(bus); + } + + // enType = (ETransport)1; + } + + private static List h_GetBusList() + { + Driver driver1 = new Driver("Surname Firstname Middlename"); + Bus bus1 = new Bus("40", driver1); + Bus bus2 = new Bus("91", driver1); + List arBus = new List(8); + arBus.Add(bus1); + arBus.Add(bus2); + return arBus; + } + + private static void h_TestSep12() + { + const int MaxNumber = 12; + Byte bb = new byte(); + new byte(); + bb = MaxNumber; + string ss = new string('1', 10); + ss = "1"; + int ii = default(int); + int kk; + + DateTime dt = DateTime.Now; + DateTime dt2 = new DateTime(2024, 09, 10); + + DateTimeOffset dto = DateTimeOffset.Now; + + Console.WriteLine($"Hello, World: {dt.ToString("yy-MM-dd")}!"); + Console.WriteLine($"Hello, World: {dt:yy-MM-dd}!"); + Console.WriteLine($"{(dt - dt2).TotalSeconds} / {(dt - dt2).Seconds}!"); + + dt.AddMinutes(1000).AddSeconds(-100); + + + h_Loops(); + } + + private static void h_Loops() + { + while (( + DateTime.Now.Second != 0 + && // and + DateTime.Now.Millisecond == 0) + || // or + (DateTime.Now.Millisecond == 1)) + { + bool bTrue = true; + bTrue = !bTrue; + //... + + short ss1; // Int16 + ushort us1; // UInt16 + int ii; // Int32 + long ll; // Int64 + } + + do + { + break; // + } while (true); + + // 1. initializer = expression + // 2. precondition = boolean + // 3. postaction = expression + for ( /* 1 */ int ii = 0; /*2*/ii < 10; /*3*/ ii++) + { + Console.WriteLine(ii); + } + + var jj = 0; + for ( /* 1 */; /*2*/; /*3*/) + { + if (jj < 10) break; + Console.WriteLine(jj); + jj++; + } + + int[] ar = { 1, 2, 3, 4 }; + } +} \ No newline at end of file