Готовая лабораторная работа 8

This commit is contained in:
nikbel2004@outlook.com 2023-12-22 20:40:53 +04:00
parent c1eb01d491
commit 7553b06d96
3 changed files with 11 additions and 5 deletions

View File

@ -21,7 +21,7 @@ namespace Tank
{ {
throw new ArgumentNullException(nameof(y)); throw new ArgumentNullException(nameof(y));
} }
if (x.GetType() != y.GetType()) if (x.GetType().Name != y.GetType().Name)
{ {
return false; return false;
} }
@ -39,6 +39,14 @@ namespace Tank
} }
if (x is DrawTank && y is DrawTank) if (x is DrawTank && y is DrawTank)
{ {
if (x.Tank as EntityTank == null)
{
throw new ArgumentNullException(nameof(x));
}
if (y.Tank as EntityTank == null)
{
throw new ArgumentNullException(nameof(y));
}
if ((x.Tank as EntityTank).AdditionalColor != (y.Tank as EntityTank).AdditionalColor) if ((x.Tank as EntityTank).AdditionalColor != (y.Tank as EntityTank).AdditionalColor)
{ {
return false; return false;

View File

@ -27,14 +27,14 @@ namespace Tank
{ {
InitializeComponent(); InitializeComponent();
panelCyan.MouseDown += panelColor_MouseDown; panelSilver.MouseDown += panelColor_MouseDown;
panelRed.MouseDown += panelColor_MouseDown; panelRed.MouseDown += panelColor_MouseDown;
panelOrange.MouseDown += panelColor_MouseDown; panelOrange.MouseDown += panelColor_MouseDown;
panelYellow.MouseDown += panelColor_MouseDown; panelYellow.MouseDown += panelColor_MouseDown;
panelGreen.MouseDown += panelColor_MouseDown; panelGreen.MouseDown += panelColor_MouseDown;
panelCyan.MouseDown += panelColor_MouseDown;
panelBlue.MouseDown += panelColor_MouseDown; panelBlue.MouseDown += panelColor_MouseDown;
panelPink.MouseDown += panelColor_MouseDown; panelPink.MouseDown += panelColor_MouseDown;
panelSilver.MouseDown += panelColor_MouseDown;
defaultColor = labelColor.BackColor; defaultColor = labelColor.BackColor;
buttonCancel.Click += (s, e) => Close(); buttonCancel.Click += (s, e) => Close();

View File

@ -21,9 +21,7 @@ namespace Tank
{ {
if (other == null || Name == null || other.Name == null) return false; if (other == null || Name == null || other.Name == null) return false;
if (Name == other.Name) return true; if (Name == other.Name) return true;
throw new NotImplementedException(); throw new NotImplementedException();
//return Name.Equals(other.Name);
} }
public override int GetHashCode() public override int GetHashCode()