PIbd-13_Ladyagin_P.D. LabWork02 Simple #4
@ -1,4 +1,4 @@
|
||||
namespace ProjectAirplaneWithRadar
|
||||
namespace ProjectAirplaneWithRadar.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
@ -39,7 +39,7 @@
|
||||
/// Высота прорисовки самолета
|
||||
/// </summary>
|
||||
public readonly int PlaneHeight = 95;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
@ -72,18 +72,18 @@
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if(_startPosX != null && _startPosY != null)
|
||||
if (_startPosX != null && _startPosY != null)
|
||||
{
|
||||
if(_startPosX.Value < 0)
|
||||
if (_startPosX.Value < 0)
|
||||
{
|
||||
_startPosX = 0;
|
||||
}
|
||||
if(_startPosY.Value < 0)
|
||||
if (_startPosY.Value < 0)
|
||||
{
|
||||
_startPosY = 0;
|
||||
}
|
||||
|
||||
if(_startPosX.Value + PlaneWidth > _pictureWidth)
|
||||
if (_startPosX.Value + PlaneWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = _pictureWidth - PlaneWidth;
|
||||
}
|
||||
@ -116,7 +116,7 @@
|
||||
{
|
||||
_startPosX = 0;
|
||||
}
|
||||
if(_startPosY.Value < 0)
|
||||
if (_startPosY.Value < 0)
|
||||
{
|
||||
_startPosY = 0;
|
||||
}
|
||||
@ -162,7 +162,7 @@
|
||||
break;
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + step < _pictureWidth - PlaneWidth)
|
||||
if (_startPosX.Value + step < _pictureWidth - PlaneWidth)
|
||||
{
|
||||
_startPosX += step;
|
||||
}
|
||||
@ -227,8 +227,8 @@
|
||||
}
|
||||
|
||||
//Корпус
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 50,100,30);
|
||||
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 50, 100, 30);
|
||||
|
||||
//Хвост
|
||||
Point[] points = {
|
||||
new Point(_startPosX.Value + 10, _startPosY.Value + 10),
|
||||
@ -259,7 +259,7 @@
|
||||
//Хвостовой элерон
|
||||
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 45, 30, 10);
|
||||
g.FillEllipse(brBlack, _startPosX.Value, _startPosY.Value + 45, 30, 10);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace ProjectAirplaneWithRadar.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность "Самолет"
|
||||
/// </summary>
|
||||
public class EntityAirplane
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Шаг перемещения автомобиля
|
||||
/// </summary>
|
||||
public double Step => Speed * 100 / Weight;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор сущности
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
public EntityAirplane(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +1,10 @@
|
||||
namespace ProjectAirplaneWithRadar
|
||||
namespace ProjectAirplaneWithRadar.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность "Самолет с радаром"
|
||||
/// </summary>
|
||||
public class EntityAirplaneWithRadar
|
||||
public class EntityAirplaneWithRadar : EntityAirplane
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
@ -33,12 +18,7 @@
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия радар
|
||||
/// </summary>
|
||||
public bool Radar { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Шаг перемещения автомобиля
|
||||
/// </summary>
|
||||
public double Step => Speed * 100 / Weight;
|
||||
public bool Radar { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса самолета с радаром
|
||||
@ -49,14 +29,11 @@
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="wheels">Шасси</param>
|
||||
/// <param name="radar">Радар</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool wheels, bool radar)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
public EntityAirplaneWithRadar(int speed, double weight, Color bodyColor, Color additionalColor, bool wheels, bool radar) : base(speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
Wheels = wheels;
|
||||
Radar = radar;
|
||||
Radar = radar;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
namespace ProjectAirplaneWithRadar
|
||||
using ProjectAirplaneWithRadar.Entities;
|
||||
|
||||
namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма работы с объектом "Самолет с радаром"
|
||||
|
Loading…
Reference in New Issue
Block a user