Kashin M.I. Lab work 3 #3
@ -20,13 +20,10 @@ namespace GasolineTanker
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush dopBrush = new SolidBrush(improvedGasolineTanker.DopColor);
|
||||
|
||||
if (improvedGasolineTanker.BodyKit)
|
||||
{
|
||||
Brush brOrange = new SolidBrush(Color.Orange);
|
||||
g.FillRectangle(brOrange, _startPosX + 25, _startPosY + 5, 100, 35);
|
||||
Brush dopBrush = new SolidBrush(improvedGasolineTanker.DopColor);
|
||||
g.FillRectangle(dopBrush, _startPosX + 25, _startPosY + 5, 100, 35);
|
||||
Brush brRed = new SolidBrush(Color.Red);
|
||||
g.FillRectangle(brRed, _startPosX + 80, _startPosY, 10, 5);
|
||||
}
|
||||
|
@ -32,10 +32,16 @@ namespace GasolineTanker
|
||||
private void ButtonCreate_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_gasolineTanker = new DrawingGasolineTanker(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_gasolineTanker.SetPosition(rnd.Next(10, 100),rnd.Next(50, 100), pictureBoxGasolineTanker.Width, pictureBoxGasolineTanker.Height);
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
_gasolineTanker = new DrawingGasolineTanker(rnd.Next(100, 300), rnd.Next(1000, 2000),color);
|
||||
SetData();
|
||||
Draw();
|
||||
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
@ -69,10 +75,19 @@ namespace GasolineTanker
|
||||
private void ButtonCreateImproved_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_gasolineTanker = new DrawingImprovedGasolineTanker(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
Color colorDop = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialogDop = new();
|
||||
if (dialogDop.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
colorDop = dialogDop.Color;
|
||||
}
|
||||
_gasolineTanker = new DrawingImprovedGasolineTanker(rnd.Next(100, 300), rnd.Next(1000, 2000), color, colorDop, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -26,9 +27,9 @@ namespace GasolineTanker
|
||||
_map = map;
|
||||
}
|
||||
|
||||
public static int operator +(MapWithSetGasolienTankerGeneric<T, U> map, T GasolineTanker)
|
||||
public static int operator +(MapWithSetGasolienTankerGeneric<T, U> map, T gasolineTanker)
|
||||
{
|
||||
return map._setGasolineTanker.Insert(GasolineTanker);
|
||||
return map._setGasolineTanker.Insert(gasolineTanker);
|
||||
}
|
||||
|
||||
public static T operator -(MapWithSetGasolienTankerGeneric<T, U> map, int position)
|
||||
@ -50,10 +51,10 @@ namespace GasolineTanker
|
||||
Shaking();
|
||||
for (int i = 0; i < _setGasolineTanker.Count; i++)
|
||||
{
|
||||
var GasolineTanker = _setGasolineTanker.Get(i);
|
||||
if (GasolineTanker != null)
|
||||
var gasolineTanker = _setGasolineTanker.Get(i);
|
||||
if (gasolineTanker != null)
|
||||
{
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, GasolineTanker);
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, gasolineTanker);
|
||||
}
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
@ -77,10 +78,10 @@ namespace GasolineTanker
|
||||
{
|
||||
for (; j > i; j--)
|
||||
{
|
||||
var GasolineTanker = _setGasolineTanker.Get(j);
|
||||
if (GasolineTanker != null)
|
||||
var gasolineTanker = _setGasolineTanker.Get(j);
|
||||
if (gasolineTanker != null)
|
||||
{
|
||||
_setGasolineTanker.Insert(GasolineTanker, i);
|
||||
_setGasolineTanker.Insert(gasolineTanker, i);
|
||||
_setGasolineTanker.Remove(j);
|
||||
break;
|
||||
}
|
||||
@ -109,8 +110,8 @@ namespace GasolineTanker
|
||||
|
||||
private void DrawGasolineTanker(Graphics g)
|
||||
{
|
||||
int width = _pictureWidth / _placeSizeWidth;
|
||||
int height = _pictureHeight / _placeSizeHeight;
|
||||
int width = _pictureWidth / _placeSizeWidth;
|
||||
int height = _pictureHeight / _placeSizeHeight;
|
||||
|
||||
for (int i = 0; i < _setGasolineTanker.Count; i++)
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ namespace GasolineTanker
|
||||
{
|
||||
_places = new T[count];
|
||||
}
|
||||
public int Insert(T GasolineTanker)
|
||||
public int Insert(T gasolineTanker)
|
||||
{
|
||||
if (_places[Count - 1] == null)
|
||||
|
||||
{
|
||||
@ -23,17 +23,17 @@ namespace GasolineTanker
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
}
|
||||
_places[0] = GasolineTanker;
|
||||
_places[0] = gasolineTanker;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public int Insert(T GasolineTanker, int position)
|
||||
public int Insert(T gasolineTanker, int position)
|
||||
{
|
||||
if (position < 0 || position >= Count) return -1;
|
||||
if (_places[position] == null)
|
||||
{
|
||||
_places[position] = GasolineTanker;
|
||||
_places[position] = gasolineTanker;
|
||||
return position;
|
||||
}
|
||||
else
|
||||
@ -44,7 +44,7 @@ namespace GasolineTanker
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
}
|
||||
_places[position] = GasolineTanker;
|
||||
_places[position] = gasolineTanker;
|
||||
return position;
|
||||
}
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user
Правильнее было вызвать Insert(T obj, 0);