лаб-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
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
|
||||
public float Weight { get; private set; }
|
||||
|
||||
public Color BodyColor { get; private set; }
|
||||
|
||||
public float Step => Speed * 100 / Weight;
|
||||
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public EntityAircraftCarrier(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
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();
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
Bitmap bmp = new Bitmap(pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
|
||||
@ -25,17 +24,20 @@ namespace AircraftCarrier
|
||||
_aircraftcarrier?.DrawTransport(gr);
|
||||
pictureBoxAircraftCarrier.Image = bmp;
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
private void SetData()
|
||||
{
|
||||
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),
|
||||
pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
|
||||
pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Скорость: {_aircraftcarrier.AircraftCarrier.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Вес: {_aircraftcarrier.AircraftCarrier.Weight}";
|
||||
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();
|
||||
}
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
@ -58,12 +60,14 @@ namespace AircraftCarrier
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
/*/private void PictureBoxAircraftCarrier_Resize(object sender, EventArgs e)
|
||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
/// Изменение размеров формы
|
||||
_aircraftcarrier?.ChangeBorders(pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
|
||||
Random rnd = new();
|
||||
_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();
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
private void PictureBoxAircraftCarrier_Resize(object sender, EventArgs e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user