лаб-2
This commit is contained in:
parent
79d9d8ec69
commit
15cd6160b9
@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftCarrier
|
||||||
|
{
|
||||||
|
internal class DrawningObjectAircraftCarrier : IDrawningObject
|
||||||
|
{
|
||||||
|
private DrawningAircraftCarrier _aircraftcarrier = null;
|
||||||
|
public DrawningObjectAircraftCarrier(DrawningAircraftCarrier aircraftcarrier)
|
||||||
|
{
|
||||||
|
_aircraftcarrier = aircraftcarrier;
|
||||||
|
}
|
||||||
|
public float Step => _aircraftcarrier?.AircraftCarrier?.Step ?? 0;
|
||||||
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||||
|
{
|
||||||
|
return _aircraftcarrier?.GetCurrentPosition() ?? default;
|
||||||
|
}
|
||||||
|
public void MoveObject(Direction direction)
|
||||||
|
{
|
||||||
|
_aircraftcarrier?.MoveTransport(direction);
|
||||||
|
}
|
||||||
|
public void SetObject(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
_aircraftcarrier.SetPosition(x, y, width, height);
|
||||||
|
}
|
||||||
|
public void DrawningObject(Graphics g)
|
||||||
|
{
|
||||||
|
_aircraftcarrier.DrawTransport(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,14 +9,10 @@ namespace AircraftCarrier
|
|||||||
internal class EntityAircraftCarrier
|
internal class EntityAircraftCarrier
|
||||||
{
|
{
|
||||||
public int Speed { get; private set; }
|
public int Speed { get; private set; }
|
||||||
|
|
||||||
public float Weight { get; private set; }
|
public float Weight { get; private set; }
|
||||||
|
|
||||||
public Color BodyColor { get; private set; }
|
public Color BodyColor { get; private set; }
|
||||||
|
|
||||||
public float Step => Speed * 100 / Weight;
|
public float Step => Speed * 100 / Weight;
|
||||||
|
public EntityAircraftCarrier(int speed, float weight, Color bodyColor)
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
|
||||||
{
|
{
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftCarrier
|
||||||
|
{
|
||||||
|
internal class EntityModernAircraftCarrier : EntityAircraftCarrier
|
||||||
|
{
|
||||||
|
public Color DopColor { get; private set; }
|
||||||
|
public bool FlightDeck { get; private set; }
|
||||||
|
public bool HangarDeck { get; private set; }
|
||||||
|
public bool Route { get; private set; }
|
||||||
|
public EntityModernAircraftCarrier(int speed, float weight, Color bodyColor, Color dopColor, bool flightDeck, bool hangarDeck, bool route) : base(speed, weight, bodyColor)
|
||||||
|
{
|
||||||
|
DopColor = dopColor;
|
||||||
|
FlightDeck = flightDeck;
|
||||||
|
HangarDeck = hangarDeck;
|
||||||
|
Route = route;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,6 @@ namespace AircraftCarrier
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
Bitmap bmp = new Bitmap(pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
|
Bitmap bmp = new Bitmap(pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
|
||||||
@ -25,17 +24,20 @@ namespace AircraftCarrier
|
|||||||
_aircraftcarrier?.DrawTransport(gr);
|
_aircraftcarrier?.DrawTransport(gr);
|
||||||
pictureBoxAircraftCarrier.Image = bmp;
|
pictureBoxAircraftCarrier.Image = bmp;
|
||||||
}
|
}
|
||||||
|
private void SetData()
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_aircraftcarrier = new DrawningAircraftCarrier();
|
|
||||||
_aircraftcarrier.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
|
||||||
_aircraftcarrier.SetPosition(rnd.Next(10, 30), rnd.Next(10, 30),
|
_aircraftcarrier.SetPosition(rnd.Next(10, 30), rnd.Next(10, 30),
|
||||||
pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
|
pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
|
||||||
toolStripStatusLabelSpeed.Text = $"Скорость: {_aircraftcarrier.AircraftCarrier.Speed}";
|
toolStripStatusLabelSpeed.Text = $"Скорость: {_aircraftcarrier.AircraftCarrier.Speed}";
|
||||||
toolStripStatusLabelWeight.Text = $"Вес: {_aircraftcarrier.AircraftCarrier.Weight}";
|
toolStripStatusLabelWeight.Text = $"Вес: {_aircraftcarrier.AircraftCarrier.Weight}";
|
||||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {_aircraftcarrier.AircraftCarrier.BodyColor.Name}";
|
toolStripStatusLabelBodyColor.Text = $"Цвет: {_aircraftcarrier.AircraftCarrier.BodyColor.Name}";
|
||||||
|
}
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random rnd = new();
|
||||||
|
_aircraftcarrier = new DrawningAircraftCarrier(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
@ -58,12 +60,14 @@ namespace AircraftCarrier
|
|||||||
}
|
}
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
/*/private void PictureBoxAircraftCarrier_Resize(object sender, EventArgs e)
|
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
/// Изменение размеров формы
|
Random rnd = new();
|
||||||
_aircraftcarrier?.ChangeBorders(pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
|
_aircraftcarrier = new DrawningAircraftCarrier(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), Color.FromArgb(rnd.Next(0, 256),rnd.Next(0, 256), rnd.Next(0, 256))));
|
||||||
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
|
||||||
private void PictureBoxAircraftCarrier_Resize(object sender, EventArgs e)
|
private void PictureBoxAircraftCarrier_Resize(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user