Переход на конструкторы

This commit is contained in:
Никита Чернышов 2022-10-07 16:52:02 +04:00
parent 32e7d7fd5f
commit 8ad0fe65dc
9 changed files with 17 additions and 19 deletions

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Warship", "Warship\Warship.csproj", "{9CFF4FD7-9721-45C9-84DC-020B509D6024}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AircraftCarrier", "Warship\AircraftCarrier.csproj", "{9CFF4FD7-9721-45C9-84DC-020B509D6024}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Warship
namespace AircraftCarrier
{
/// <summary>
/// Направление перемещения

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Warship
namespace AircraftCarrier
{
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
@ -45,10 +45,9 @@ namespace Warship
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес корабля</param>
/// <param name="bodyColor">Цвет</param>
public void Init(int speed, float weight, Color bodyColor)
public DrawingWarship(int speed, float weight, Color bodyColor)
{
Ship = new EntityWarship();
Ship.Init(speed, weight, bodyColor);
Ship = new EntityWarship(speed, weight, bodyColor);
}
/// <summary>
/// Установка позиции корабля

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Warship
namespace AircraftCarrier
{
/// <summary>
/// Класс-сущность "Военный корабль"
@ -34,7 +34,7 @@ namespace Warship
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
/// <returns></returns>
public void Init(int speed, float weight, Color bodyColor)
public EntityWarship(int speed, float weight, Color bodyColor)
{
Random rnd = new Random();
Speed = speed <= 0 ? rnd.Next(50, 100) : speed;

View File

@ -1,4 +1,4 @@
namespace Warship
namespace AircraftCarrier
{
partial class FormShip
{
@ -96,7 +96,7 @@
// buttonLeft
//
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::Warship.Properties.Resources.стрелка;
this.buttonLeft.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелка;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(657, 375);
this.buttonLeft.Name = "buttonLeft";
@ -108,7 +108,7 @@
// buttonDown
//
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::Warship.Properties.Resources.стрелкаbott;
this.buttonDown.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелкаbott;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(693, 375);
this.buttonDown.Name = "buttonDown";
@ -120,7 +120,7 @@
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::Warship.Properties.Resources.стрелкаtop;
this.buttonUp.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелкаtop;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(693, 339);
this.buttonUp.Name = "buttonUp";
@ -132,7 +132,7 @@
// buttonRight
//
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.BackgroundImage = global::Warship.Properties.Resources.стрелкаright;
this.buttonRight.BackgroundImage = global::AircraftCarrier.Properties.Resources.стрелкаright;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(729, 375);
this.buttonRight.Name = "buttonRight";

View File

@ -1,4 +1,4 @@
namespace Warship
namespace AircraftCarrier
{
public partial class FormShip : Form
{
@ -25,8 +25,7 @@ namespace Warship
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_ship = new DrawingWarship();
_ship.Init(rnd.Next(50, 100), rnd.Next(20000, 30000),
_ship = new DrawingWarship(rnd.Next(50, 100), rnd.Next(20000, 30000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_ship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
pictureBoxShip.Width, pictureBoxShip.Height);

View File

@ -1,4 +1,4 @@
namespace Warship
namespace AircraftCarrier
{
internal static class Program
{

View File

@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace Warship.Properties {
namespace AircraftCarrier.Properties {
using System;
@ -39,7 +39,7 @@ namespace Warship.Properties {
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Warship.Properties.Resources", typeof(Resources).Assembly);
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AircraftCarrier.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;