|
using System;
using System.Collections.Generic;
using System.Text;
namespace DataStructuresDotNet.Visitors
{
/// <summary>
///
/// </summary>
public sealed class SumVisitor : IVisitor<int>
{
#region Globals
private int sum;
#endregion
#region Construction
/// <summary>
/// Initializes a new instance of the <see cref="SumVisitor"/> class.
/// </summary>
public SumVisitor() { }
#endregion
#region IVisitor<int> Members
/// <summary>
/// Visits the specified object.
/// </summary>
/// <param name="obj">The object.</param>
public void Visit(int obj)
{
sum += obj;
}
/// <summary>
/// Gets a value indicating whether this instance is done performing it's work..
/// </summary>
/// <returns></returns>
/// <value><c>true</c> if this instance is done; otherwise, <c>false</c>.</value>
public bool HasCompleted
{
get
{
return false;
}
}
#endregion
#region Public Members
/// <summary>
/// Gets the sum accumulated by this SumVisitor.
/// </summary>
/// <value>The sum.</value>
public int Sum
{
get
{
return sum;
}
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
The author is a software consultant in South Africa, specializing in bespoke software solutions.