Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
using System.Collections;
using System.Drawing;
class Triangle : IEnumerable
{
public Point A, B, C;
// declare method required by IEnumerable
public IEnumberator GetEnumerator()
{
return new PointEnumerator(this);
}
// Inner class implements IEnumerator interface
private class PointEnumerator : IEnumerator
{
private int position = -1;
private Triangle t;
// constructor
public PointEnumerator(Triangle t)
{
this.t = t; // make a local copy of the Triangle object
}
// Declare the public method required by IEnumerator
public bool MoveNext()
{
if (position < (3 - 1) // three points in triangle,
// subtract one for starting at 0
position++;
return true;
}
else
{
return false;
}
}
// declare the public method required by IEnumerator
public void Reset()
{
position = -1;
}
// declare the public property required by IEnumerator
public object Current
{
get
{
switch (position)
{
case 0:
return t.A.ToObject();
break;
case 1:
return t.B.ToObject();
break;
case 2:
return t.C.ToObject();
break;
default:
return null;
break;
}
}
}
}
}