pibd-12 Tangatarov.I.A. LabWork03 Base #11

Closed
sqdselo wants to merge 12 commits from LabWork03 into LabWork02
5 changed files with 20 additions and 35 deletions
Showing only changes of commit dc01587054 - Show all commits

View File

@ -1,5 +1,4 @@
using HoistingCrane.Drawning;
using System;
namespace HoistingCrane.CollectionGenericObjects
{
public abstract class AbstractCompany
@ -42,13 +41,13 @@ namespace HoistingCrane.CollectionGenericObjects
arr.SetMaxCount = GetMaxCount;
}
public static bool operator +(AbstractCompany company, DrawningTrackedVehicle car)
public static int operator +(AbstractCompany company, DrawningTrackedVehicle car)
{
return company.arr?.Insert(car) ?? false;
return company.arr?.Insert(car) ?? 0;
}
public static bool operator -(AbstractCompany company, int position)
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
{
return company.arr?.Remove(position) ?? false;
return company.arr?.Remove(position);
}
public DrawningTrackedVehicle? GetRandomObject()

View File

@ -1,7 +1,4 @@
using HoistingCrane.Drawning;
using System;
using System.Collections.Specialized;
namespace HoistingCrane.CollectionGenericObjects
{
public class Garage : AbstractCompany

View File

@ -1,5 +1,4 @@
using System;
namespace HoistingCrane.CollectionGenericObjects
namespace HoistingCrane.CollectionGenericObjects
{
public interface ICollectionGenericObjects<T>
where T: class
@ -17,7 +16,7 @@ namespace HoistingCrane.CollectionGenericObjects
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
bool Insert(T obj);
int Insert(T obj);
/// <summary>
/// Добавление элемента в коллекцию на определенную позицию
/// </summary>
@ -30,7 +29,7 @@ namespace HoistingCrane.CollectionGenericObjects
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
bool Remove(int position);
T? Remove(int position);
T? Get(int position);
}
}

View File

@ -1,5 +1,4 @@
using System;
namespace HoistingCrane.CollectionGenericObjects
namespace HoistingCrane.CollectionGenericObjects
{
public class MassivGenericObjects<T> : ICollectionGenericObjects<T> where T : class
{
@ -31,16 +30,16 @@ namespace HoistingCrane.CollectionGenericObjects
return null;
}
public bool Insert(T obj)
public int Insert(T obj)
{
for(int i = 0; i < Count; i++)
{
if (arr[i] == null) {
arr[i] = obj;
return true;
Insert(obj,i);
return 1;
}
}
return false;
return 0;
}
public bool Insert(T obj, int position)
@ -81,14 +80,15 @@ namespace HoistingCrane.CollectionGenericObjects
return false;
}
public bool Remove(int position)
public T? Remove(int position)
{
if(position < 0 || position >= arr.Length || arr[position] == null)
if(position >= 0 && position < Count)
{
return false;
arr[position] = null;
return arr[position];
}
arr[position] = null;
return true;
return arr[position];
}
}
}

View File

@ -1,15 +1,5 @@
using HoistingCrane.CollectionGenericObjects;
using HoistingCrane.Drawning;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HoistingCrane
{
public partial class FormCarCollection : Form
@ -49,7 +39,7 @@ namespace HoistingCrane
default:
return;
}
if (_company + drawning)
if ((_company + drawning) == 1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -91,7 +81,7 @@ namespace HoistingCrane
return;
}
int pos = Convert.ToInt32(maskedTextBox.Text);
if (_company - pos)
if ((_company - pos) == null)
{
MessageBox.Show("Объект удален!");
pictureBox.Image = _company.Show();