Лабораторная работа 3
This commit is contained in:
parent
7dda1f708a
commit
ec6e19c626
@ -20,13 +20,10 @@ namespace GasolineTanker
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
Brush dopBrush = new SolidBrush(improvedGasolineTanker.DopColor);
|
|
||||||
|
|
||||||
if (improvedGasolineTanker.BodyKit)
|
if (improvedGasolineTanker.BodyKit)
|
||||||
{
|
{
|
||||||
Brush brOrange = new SolidBrush(Color.Orange);
|
Brush dopBrush = new SolidBrush(improvedGasolineTanker.DopColor);
|
||||||
g.FillRectangle(brOrange, _startPosX + 25, _startPosY + 5, 100, 35);
|
g.FillRectangle(dopBrush, _startPosX + 25, _startPosY + 5, 100, 35);
|
||||||
Brush brRed = new SolidBrush(Color.Red);
|
Brush brRed = new SolidBrush(Color.Red);
|
||||||
g.FillRectangle(brRed, _startPosX + 80, _startPosY, 10, 5);
|
g.FillRectangle(brRed, _startPosX + 80, _startPosY, 10, 5);
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,16 @@ namespace GasolineTanker
|
|||||||
private void ButtonCreate_Click_1(object sender, EventArgs e)
|
private void ButtonCreate_Click_1(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
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)));
|
Color color = 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);
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
_gasolineTanker = new DrawingGasolineTanker(rnd.Next(100, 300), rnd.Next(1000, 2000),color);
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
@ -69,10 +75,19 @@ namespace GasolineTanker
|
|||||||
private void ButtonCreateImproved_Click(object sender, EventArgs e)
|
private void ButtonCreateImproved_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_gasolineTanker = new DrawingImprovedGasolineTanker(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
Color color = 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)),
|
ColorDialog dialog = new();
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
{
|
||||||
|
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();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.Metrics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -26,9 +27,9 @@ namespace GasolineTanker
|
|||||||
_map = map;
|
_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)
|
public static T operator -(MapWithSetGasolienTankerGeneric<T, U> map, int position)
|
||||||
@ -50,10 +51,10 @@ namespace GasolineTanker
|
|||||||
Shaking();
|
Shaking();
|
||||||
for (int i = 0; i < _setGasolineTanker.Count; i++)
|
for (int i = 0; i < _setGasolineTanker.Count; i++)
|
||||||
{
|
{
|
||||||
var GasolineTanker = _setGasolineTanker.Get(i);
|
var gasolineTanker = _setGasolineTanker.Get(i);
|
||||||
if (GasolineTanker != null)
|
if (gasolineTanker != null)
|
||||||
{
|
{
|
||||||
return _map.CreateMap(_pictureWidth, _pictureHeight, GasolineTanker);
|
return _map.CreateMap(_pictureWidth, _pictureHeight, gasolineTanker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new(_pictureWidth, _pictureHeight);
|
return new(_pictureWidth, _pictureHeight);
|
||||||
@ -77,10 +78,10 @@ namespace GasolineTanker
|
|||||||
{
|
{
|
||||||
for (; j > i; j--)
|
for (; j > i; j--)
|
||||||
{
|
{
|
||||||
var GasolineTanker = _setGasolineTanker.Get(j);
|
var gasolineTanker = _setGasolineTanker.Get(j);
|
||||||
if (GasolineTanker != null)
|
if (gasolineTanker != null)
|
||||||
{
|
{
|
||||||
_setGasolineTanker.Insert(GasolineTanker, i);
|
_setGasolineTanker.Insert(gasolineTanker, i);
|
||||||
_setGasolineTanker.Remove(j);
|
_setGasolineTanker.Remove(j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace GasolineTanker
|
|||||||
{
|
{
|
||||||
_places = new T[count];
|
_places = new T[count];
|
||||||
}
|
}
|
||||||
public int Insert(T GasolineTanker)
|
public int Insert(T gasolineTanker)
|
||||||
{
|
{
|
||||||
if (_places[Count - 1] == null)
|
if (_places[Count - 1] == null)
|
||||||
{
|
{
|
||||||
@ -23,17 +23,17 @@ namespace GasolineTanker
|
|||||||
{
|
{
|
||||||
_places[i] = _places[i - 1];
|
_places[i] = _places[i - 1];
|
||||||
}
|
}
|
||||||
_places[0] = GasolineTanker;
|
_places[0] = gasolineTanker;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
public int Insert(T GasolineTanker, int position)
|
public int Insert(T gasolineTanker, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count) return -1;
|
if (position < 0 || position >= Count) return -1;
|
||||||
if (_places[position] == null)
|
if (_places[position] == null)
|
||||||
{
|
{
|
||||||
_places[position] = GasolineTanker;
|
_places[position] = gasolineTanker;
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -44,7 +44,7 @@ namespace GasolineTanker
|
|||||||
{
|
{
|
||||||
_places[i] = _places[i - 1];
|
_places[i] = _places[i - 1];
|
||||||
}
|
}
|
||||||
_places[position] = GasolineTanker;
|
_places[position] = gasolineTanker;
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user