diff --git a/LocomotivesAdvanced/LocomotivesAdvanced/DrawningEllipseOrnament.cs b/LocomotivesAdvanced/LocomotivesAdvanced/DrawningEllipseOrnament.cs
index d3633d4..e3580b2 100644
--- a/LocomotivesAdvanced/LocomotivesAdvanced/DrawningEllipseOrnament.cs
+++ b/LocomotivesAdvanced/LocomotivesAdvanced/DrawningEllipseOrnament.cs
@@ -6,6 +6,10 @@
public int WheelsNum
{
+ get
+ {
+ return (int)wheelsNumber;
+ }
set
{
if (value < 2 || value > 4)
diff --git a/LocomotivesAdvanced/LocomotivesAdvanced/DrawningRectOrnament.cs b/LocomotivesAdvanced/LocomotivesAdvanced/DrawningRectOrnament.cs
index e6189ea..7a8ee24 100644
--- a/LocomotivesAdvanced/LocomotivesAdvanced/DrawningRectOrnament.cs
+++ b/LocomotivesAdvanced/LocomotivesAdvanced/DrawningRectOrnament.cs
@@ -6,6 +6,10 @@
public int WheelsNum
{
+ get
+ {
+ return (int)wheelsNumber;
+ }
set
{
if (value < 2 || value > 4)
diff --git a/LocomotivesAdvanced/LocomotivesAdvanced/DrawningWheels.cs b/LocomotivesAdvanced/LocomotivesAdvanced/DrawningWheels.cs
index 552ed41..32aee4d 100644
--- a/LocomotivesAdvanced/LocomotivesAdvanced/DrawningWheels.cs
+++ b/LocomotivesAdvanced/LocomotivesAdvanced/DrawningWheels.cs
@@ -6,6 +6,10 @@
public int WheelsNum
{
+ get
+ {
+ return (int)wheelsNumber;
+ }
set
{
if (value < 2 || value > 4)
diff --git a/LocomotivesAdvanced/LocomotivesAdvanced/ExtentionLocomotive.cs b/LocomotivesAdvanced/LocomotivesAdvanced/ExtentionLocomotive.cs
index cafbc25..849dfaf 100644
--- a/LocomotivesAdvanced/LocomotivesAdvanced/ExtentionLocomotive.cs
+++ b/LocomotivesAdvanced/LocomotivesAdvanced/ExtentionLocomotive.cs
@@ -17,7 +17,7 @@
public static string GetDataForSave(this DrawningLocomotive drawningLocomotive)
{
var locomotive = drawningLocomotive.Locomotive;
- var str = $"{locomotive.Speed}{_separatorForObject}{locomotive.Weight}{_separatorForObject}{locomotive.BodyColor.Name}";
+ var str = $"{locomotive.Speed}{_separatorForObject}{locomotive.Weight}{_separatorForObject}{locomotive.BodyColor.Name}{_separatorForObject}{drawningLocomotive.AdditionalElements.WheelsNum}{_separatorForObject}{drawningLocomotive.AdditionalElements.GetType().Name}";
if (locomotive is not EntityWarmlyLocomotive warmlyLocomotive)
{
return str;
@@ -32,19 +32,33 @@
public static DrawningLocomotive CreateDrawningLocomotive(this string info)
{
string[] strs = info.Split(_separatorForObject);
- if (strs.Length == 3)
+ DrawningLocomotive recreatedLocomotive = null;
+ if (strs.Length == 5)
{
- return new DrawningLocomotive(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]));
+ recreatedLocomotive = new DrawningLocomotive(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]));
}
- if (strs.Length == 6)
+ if (strs.Length == 8)
{
- return new DrawningWarmlyLocomotive
+ recreatedLocomotive = new DrawningWarmlyLocomotive
(
Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), 160, 85,
- Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5])
+ Color.FromName(strs[5]), Convert.ToBoolean(strs[6]), Convert.ToBoolean(strs[7])
);
}
- return null;
+ switch (strs[4])
+ {
+ case "DrawningWheels":
+ recreatedLocomotive.AdditionalElements = new DrawningWheels();
+ break;
+ case "DrawningRectOrnament":
+ recreatedLocomotive.AdditionalElements = new DrawningRectOrnament();
+ break;
+ case "DrawningEllipseOrnament":
+ recreatedLocomotive.AdditionalElements = new DrawningEllipseOrnament();
+ break;
+ }
+ recreatedLocomotive.AdditionalElements.WheelsNum = Convert.ToInt32(strs[3]);
+ return recreatedLocomotive;
}
}
}
diff --git a/LocomotivesAdvanced/LocomotivesAdvanced/IDrawningAdditionalElements.cs b/LocomotivesAdvanced/LocomotivesAdvanced/IDrawningAdditionalElements.cs
index 968e2f7..f0a6c3a 100644
--- a/LocomotivesAdvanced/LocomotivesAdvanced/IDrawningAdditionalElements.cs
+++ b/LocomotivesAdvanced/LocomotivesAdvanced/IDrawningAdditionalElements.cs
@@ -8,7 +8,7 @@
///
/// Свойство получения количества колёс
///
- public int WheelsNum { set; }
+ public int WheelsNum { get; set; }
///
/// Отрисовка колёс
///