Morozov V.S. LabWork2 #2
@ -16,11 +16,11 @@ namespace AirPlaneWithRadar
|
||||
private int? pictureHeight = null;
|
||||
protected readonly int plainWidth = 120;
|
||||
protected readonly int plainHeight =70;
|
||||
public void Init (int speed, float weight, Color bodycolor)
|
||||
public DrawingPlain(int speed, float weight, Color bodycolor)
|
||||
{
|
||||
Plain = new EntetyPlain ();
|
||||
Plain.Init (speed, weight, bodycolor);
|
||||
Plain = new EntetyPlain(speed, weight, bodycolor);
|
||||
}
|
||||
|
||||
public void setPosition(int x,int y,int width,int height)
|
||||
{
|
||||
if (x + plainWidth > width || y + plainHeight > height || plainHeight > height || plainWidth > width || x <0 || y<0)
|
||||
@ -66,27 +66,37 @@ namespace AirPlaneWithRadar
|
||||
}
|
||||
|
||||
Pen pen = new Pen(Color.Black);
|
||||
|
||||
|
||||
|
||||
g.DrawRectangle(pen, startPosX, startPosY, 20, 30);
|
||||
g.DrawRectangle(pen, startPosX, startPosY + 30, 100, 30);
|
||||
g.DrawRectangle(pen, startPosX+100, startPosY + 40, 20, 15);
|
||||
|
||||
//koleso1
|
||||
g.DrawRectangle(pen, startPosX + 30, startPosY + 60, 5, 10);
|
||||
g.DrawEllipse(pen, startPosX+28, startPosY+70, 9, 9);
|
||||
|
||||
//koleso2
|
||||
g.DrawRectangle(pen, startPosX + 80, startPosY + 60, 5, 10);
|
||||
g.DrawEllipse(pen, startPosX + 78, startPosY + 70, 9, 9);
|
||||
|
||||
|
||||
|
||||
//Korpys
|
||||
Brush br = new SolidBrush(Plain?.BodyColor ?? Color.Black);
|
||||
g.FillRectangle(br, startPosX+3, startPosY + 33, 94, 24);
|
||||
g.FillRectangle(br, startPosX+1, startPosY+1, 19, 29);
|
||||
|
||||
|
||||
//krilya
|
||||
Brush brWings = new SolidBrush(Color.Black);
|
||||
g.FillRectangle(brWings, startPosX + 30, startPosY + 40, 40, 8);
|
||||
|
||||
|
||||
//cabina
|
||||
Brush brCabine = new SolidBrush(Color.Blue);
|
||||
g.FillRectangle(brCabine, startPosX + 101, startPosY + 41, 19, 14);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void ChangeBorders(int width, int height)
|
||||
|
@ -14,13 +14,14 @@ namespace AirPlaneWithRadar
|
||||
public Color BodyColor { get; private set; }
|
||||
public float Step => Speed * 100 / Weight;
|
||||
|
||||
public void Init (int speed, float weight, Color bodycolor)
|
||||
public EntetyPlain(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rd = new Random();
|
||||
|
||||
Speed = speed <= 0 ? rd.Next(50,150):speed;
|
||||
Weight = weight <= 0 ? rd.Next(40, 70) :weight;
|
||||
BodyColor = bodycolor;
|
||||
Speed = speed <= 0 ? rd.Next(50, 150) : speed;
|
||||
Weight = weight <= 0 ? rd.Next(40, 70) : weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ namespace AirPlaneWithRadar
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_plain = new DrawingPlain();
|
||||
_plain = new DrawingPlain(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
|
||||
_plain.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
|
||||
_plain.setPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxPlain.Width, pictureBoxPlain.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_plain.Plain.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_plain.Plain.Weight}";
|
||||
|
Loading…
Reference in New Issue
Block a user