Advertisement
FHRL

círculos V0.0.4(metodo EqualsWithoutIdentificadorWithMargin)

Mar 14th, 2022
1,255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.37 KB | None | 0 0
  1. /*
  2.  * Created by SharpDevelop.
  3.  * User: Usuario
  4.  * Date: 28/02/2022
  5.  * Time: 08:25 p. m.
  6.  * Version: 0.0.4
  7.  * To change this template use Tools | Options | Coding | Edit Standard Headers.
  8.  */
  9. using System;
  10. using System.Drawing;
  11.  
  12. namespace Actividad_1
  13. {
  14.     /// <summary>
  15.     /// Description of circulos.
  16.     /// </summary>
  17.     public struct circulos : IEquatable<circulos>
  18.     {
  19.         //int member;
  20.         string identificador{ get; set; }// { get; set; }
  21.         Point centro{ get; set; }
  22.         int radio{ get; set; } // this is just an example member, replace it with your own struct members!
  23.        
  24.         #region Equals and GetHashCode implementation
  25.         // The code in this region is useful if you want to use this structure in collections.
  26.         // If you don't need it, you can just remove the region and the ": IEquatable<circulos>" declaration.
  27.         public circulos(Point centro,int radio):this(){
  28.             this.centro=new Point(centro.X,centro.Y);
  29.             this.radio=radio;
  30.         }
  31.         public override bool Equals(object obj)
  32.         {
  33.             if (obj is circulos)
  34.                 return Equals((circulos)obj); // use Equals method below
  35.             else
  36.                 return false;
  37.         }
  38.        
  39.         public bool EqualsWithoutIdentificadorWithMargin(circulos other,int margen)
  40.         {
  41.             // add comparisions for all members here
  42.            
  43.             return(this.centro.X <= other.centro.X+margen)&&(this.centro.X+margen <= other.centro.X)
  44.                 &&(this.centro.Y <= other.centro.Y+margen)&&(this.centro.Y+margen <= other.centro.Y)//.Equals(other.centro))
  45.                 &&(this.radio <= other.radio+margen)&&(this.radio+margen <= other.radio);
  46.         }
  47.         public bool EqualsWithoutIdentificador(circulos other)
  48.         {
  49.             // add comparisions for all members here
  50.            
  51.             return(this.centro.Equals(other.centro))
  52.                 &&(this.radio.Equals(other.radio));
  53.         }
  54.         public bool Equals(circulos other)
  55.         {
  56.             // add comparisions for all members here
  57.            
  58.             return(this.identificador.Equals(other.identificador))
  59.                 &&(this.EqualsWithoutIdentificador(other));
  60.         }
  61.        
  62.         public override int GetHashCode()
  63.         {
  64.             // combine the hash codes of all members here (e.g. with XOR operator ^)
  65.             return identificador.GetHashCode()^centro.GetHashCode()^radio.GetHashCode();
  66.         }
  67.        
  68.         public static bool operator ==(circulos left, circulos right)
  69.         {
  70.             return left.Equals(right);
  71.         }
  72.        
  73.         public static bool operator !=(circulos left, circulos right)
  74.         {
  75.             return !left.Equals(right);
  76.         }
  77.         #endregion
  78.     }
  79. }
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement