недоделанная первая лаба
This commit is contained in:
parent
ac4f1fc1e1
commit
65004508a9
24
DoubleDeckerBus/DoubleDeckerBus/DirectionType.cs
Normal file
24
DoubleDeckerBus/DoubleDeckerBus/DirectionType.cs
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
namespace DoubleDeckerBus;
|
||||
|
||||
public enum DirectionType
|
||||
{ /// <summary>
|
||||
/// вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
|
||||
/// <summary>
|
||||
/// вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
|
||||
/// <summary>
|
||||
/// влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
|
||||
/// <summary>
|
||||
/// вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
102
DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs
Normal file
102
DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoubleDeckerBus;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class DrawingDoubleDeckerBus
|
||||
{
|
||||
public EntityDoubleDeckerBus? EntityDoubleDeckerBus { get; private set; }
|
||||
|
||||
private int? _pictureWidth;
|
||||
|
||||
private int? _pictureHeight;
|
||||
|
||||
private int? _startPosX;
|
||||
|
||||
private int? _startPosY;
|
||||
|
||||
private readonly int _DrawingBusWidth;
|
||||
|
||||
private readonly int _DrawingBusHight;
|
||||
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine)
|
||||
{
|
||||
EntityDoubleDeckerBus = new EntityDoubleDeckerBus();
|
||||
EntityDoubleDeckerBus.Init(speed, weight, bodyColor, additionalColor, bodyKit, wing, sportLine);
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
public bool SetPictureSize(int width, int hight)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = hight;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityDoubleDeckerBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - EntityDoubleDeckerBus.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityDoubleDeckerBus.Step;
|
||||
}
|
||||
return true;
|
||||
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - EntityDoubleDeckerBus.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityDoubleDeckerBus.Step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + EntityDoubleDeckerBus.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityDoubleDeckerBus.Step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + EntityDoubleDeckerBus.Step < _pictureHeight)
|
||||
{
|
||||
_startPosX += (int)EntityDoubleDeckerBus.Step;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawTrasnport(Graphics g)
|
||||
{
|
||||
if (EntityDoubleDeckerBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
53
DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
Normal file
53
DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
|
||||
namespace DoubleDeckerBus;
|
||||
public class EntityDoubleDeckerBus
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
|
||||
public double Weight { get; private set; }
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия обвеса
|
||||
/// </summary>
|
||||
public bool BodyKit { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия антикрыла
|
||||
/// </summary>
|
||||
public bool Wing { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия гоночной полосы
|
||||
/// </summary>
|
||||
public bool SportLine { 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>
|
||||
/// <param name="additionalColor"></param>
|
||||
/// <param name="bodyKit"></param>
|
||||
/// <param name="wing"></param>
|
||||
/// <param name="sportLine"></param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
BodyKit = bodyKit;
|
||||
Wing = wing;
|
||||
SportLine = sportLine;
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace DoubleDeckerBus
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
namespace DoubleDeckerBus
|
||||
{
|
||||
partial class Form1
|
||||
partial class FormDoubleDeckerBus
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
@ -23,15 +23,15 @@
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
this.Text = "FormDoubleDeckerBus";
|
||||
}
|
||||
|
||||
#endregion
|
20
DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs
Normal file
20
DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DoubleDeckerBus
|
||||
{
|
||||
public partial class FormDoubleDeckerBus : Form
|
||||
{
|
||||
public FormDoubleDeckerBus()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace DoubleDeckerBus
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormDoubleDeckerBus());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user