Доп задание 1

This commit is contained in:
георгий левченко 2024-02-19 10:02:02 +04:00
parent 0b983f86b7
commit 8861b13b44
2 changed files with 14 additions and 6 deletions

View File

@ -49,10 +49,10 @@ public class DrawningTrolleybus
/// <param name="additionalColor"></param>
/// <param name="batteryCompartment"></param>
/// <param name="horns"></param>
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool batteryCompartment, bool horns)
///
public void Init(EntityTrolleybus _Tr)
{
EntityTrolleybus = new EntityTrolleybus();
EntityTrolleybus.Init(speed, weight, bodyColor, additionalColor, batteryCompartment, horns);
EntityTrolleybus = _Tr;
_pictureHeight = null;
_pictureWidth = null;
_startPosX = null;
@ -67,7 +67,6 @@ public class DrawningTrolleybus
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
public bool SetPictureSize(int width, int height)
{
//TODO проверка, что объект "влезает" в размеры поля
//если влезает, сохраняем границы и корректируем позицию объекта, если она уже была установлена
if (_drawningVehicleWidth > width || _drawningVehicleHeight > height)
{

View File

@ -4,6 +4,8 @@
{
private DrawningTrolleybus? _drawningTrolleybus;
EntityTrolleybus? _Trolleybus;
public FormTrolleybus()
{
InitializeComponent();
@ -21,14 +23,21 @@
{
Random random = new();
_drawningTrolleybus = new DrawningTrolleybus();
_drawningTrolleybus.Init(random.Next(100, 300), random.Next(1000, 3000),
_Trolleybus = new EntityTrolleybus();
_Trolleybus.Init(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_drawningTrolleybus = new DrawningTrolleybus();
_drawningTrolleybus.Init(_Trolleybus);
//_drawningTrolleybus.Init(random.Next(100, 300), random.Next(1000, 3000),
// Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
// Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
// Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_drawningTrolleybus.SetPictureSize(pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
_drawningTrolleybus.SetPosition(random.Next(10, 100), random.Next(10, 100), pictureBoxTrolleybus.Width, pictureBoxTrolleybus.Height);
Draw();
}
private void ButtonMove_Click(object sender, EventArgs e)