コード例 #1
0
 public int CompareTo(IShape other)
 {
     if (other == null)
     {
         return(1);
     }
     if (Area.CompareTo(other.Area) == 0)
     {
         return(NumberOfSides.CompareTo(other.NumberOfSides));
     }
     else
     {
         return(Area.CompareTo(other.Area));
     }
 }
コード例 #2
0
 public override string ToString()
 {
     return(NumberOfSides.ToString() + "-gon");
 }
コード例 #3
0
        public int RemoveSide(int index)
        {
            int result = 0;

            if (index < 0)
            {
                throw new ArgumentException("Must count a side from at least 0.  You asked to remove a side less than the 0th side from a die.");
            }
            if (index < NumberOfSides)
            {
                result = SideSymbolIds[index];
                SideSymbolIds[index] = Blank;
                return(result);
            }
            throw new ArgumentException("Cannot reference side " + index.ToString() + ": only " + NumberOfSides.ToString() + " sides on this die.  (Sides counted from 0)");
        }
コード例 #4
0
 public Circle(NumberOfSides numberOfSides)
 {
     NumberOfSides = numberOfSides;
 }