Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Computershik73 authored Jan 3, 2018
1 parent a57dc61 commit c21f97d
Show file tree
Hide file tree
Showing 41 changed files with 1,918 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Laba3/Laba2/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
74 changes: 74 additions & 0 deletions Laba3/Laba2/ClassArray.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Laba2
{
class ClassArray<T> where T : ITransport
{

private Dictionary<int, T> places;
private int maxCount;
//private T[] places;
private T defaultValue;


public ClassArray(int sizes,T defVal)
{
defaultValue = defVal;
places = new Dictionary<int, T>();
maxCount = sizes;

}


public static int operator +(ClassArray<T> p,T car)
{
if(p.places.Count==p.maxCount)
{
return -1;
}
for (int i=0;i<p.places.Count;i++)
{
if (p.CheckFreePlace(i))
{
p.places.Add(i,car);
return i;
}
}
p.places.Add(p.places.Count, car);
return p.places.Count - 1;

}
public static T operator -(ClassArray<T> p,int index)
{
if (p.places.ContainsKey(index))
{
T car = p.places[index];
p.places.Remove(index);
return car;
}
return p.defaultValue;
}
private bool CheckFreePlace(int index)
{

return !places.ContainsKey(index);
}
public T this[int ind]
{
get{
if (places.ContainsKey(ind))
{
return places[ind];
}
return defaultValue;
}
}


}

}
272 changes: 272 additions & 0 deletions Laba3/Laba2/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c21f97d

Please sign in to comment.