7 changed files with 285 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net8.0</TargetFramework> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="ClassLibrary1\**" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<EmbeddedResource Remove="ClassLibrary1\**" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="ClassLibrary1\**" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="Pi232._0920\Pi232._0920.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -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 |
|||
@ -0,0 +1,54 @@ |
|||
namespace Pi232._0920; |
|||
|
|||
|
|||
public class Transport |
|||
{ |
|||
/// <summary>
|
|||
/// тип транспортного средства
|
|||
/// </summary>
|
|||
public ETransport Type { get; set; } |
|||
} |
|||
public class Bus: Transport |
|||
{ |
|||
#region Свойства
|
|||
|
|||
/// <summary>
|
|||
/// Номер маршрута
|
|||
/// </summary>
|
|||
public string RouteNum { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Фамилия водителя
|
|||
/// </summary>
|
|||
public Driver CurrentDriver { get; set; } |
|||
|
|||
|
|||
#endregion
|
|||
|
|||
#region конструкторы
|
|||
|
|||
/// <summary>
|
|||
/// .ctor
|
|||
/// </summary>
|
|||
/// <param name="routeNum"></param>
|
|||
/// <param name="driver"></param>
|
|||
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}"; |
|||
} |
|||
} |
|||
@ -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 |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace Pi232._0920; |
|||
|
|||
public enum ETransport |
|||
{ |
|||
Unknown = 0, |
|||
Bus = 1 |
|||
} |
|||
@ -0,0 +1,98 @@ |
|||
using Pi232._0920; |
|||
|
|||
namespace ConsoleApp1; |
|||
|
|||
class Program |
|||
{ |
|||
static void Main(string[] args) |
|||
{ |
|||
// h_TestSep12();
|
|||
List<Bus> arBus = h_GetBusList(); |
|||
foreach (Bus bus in arBus) |
|||
{ |
|||
Console.WriteLine(bus); |
|||
} |
|||
|
|||
// enType = (ETransport)1;
|
|||
} |
|||
|
|||
private static List<Bus> h_GetBusList() |
|||
{ |
|||
Driver driver1 = new Driver("Surname Firstname Middlename"); |
|||
Bus bus1 = new Bus("40", driver1); |
|||
Bus bus2 = new Bus("91", driver1); |
|||
List<Bus> arBus = new List<Bus>(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 }; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue