[SOLVED] Using System;

$25

File Name: Using_System;.zip
File Size: 122.46 KB

5/5 - (1 vote)

Using System;

using System.Collections.Generic;

using Formulas;

namespace SS

{

///

///

///

public class CircularException : Exception

{

}

///

///namenull

///

public class InvalidNameException : Exception

{

}

///

///

///

public struct FormulaError

{

///

/// FormulaError

///

public FormulaError(String reason)

: this()

{

Reason = reason;

}

///

///The reason why this FormulaError was created. FormulaError

///

public string Reason { get; private set; }

}

///

/// AbstractSpreadsheetobject

/// strings

///A15a15XY32BC7ZX07hello

///

///

/// 1string2double3formula Excel

///

/// 1string2double3FormulaError Excel

/// stringstring

/// doubledouble

/// FormuladoubleFormulaError

/// Formula
valuedoubleFormulaErrordoubleFormula.Evaluate

///

///A1B1 * 2B1C1 * 2C1A1 * 2
/// A1B1C1A1

///

public abstract class AbstractSpreadsheet

{

///

/// Enumerates the names of all the non-empty cells in the spreadsheet.

///

public abstract IEnumerable GetNamesOfAllNonemptyCells();

///

/// namenullinvalidInvalidNameException
stringdoubleFormula

///

public abstract object GetCellContents(String name);

///

/// namenullinvalidInvalidNameException

///

/// nameA1B1A1 * 2C1B1 + A1{A1B1C1}

///

public abstract ISet SetCellContents(String name, double number);

///

/// textnullArgumentNullException

/// namenullInvalidNameException

/// text
///nameA1B1A1 * 2C1B1 + A1return{A1B1C1}

///

public abstract ISet SetCellContents(String name, String text);

///

/// formula

/// namenullInvalidNameException

/// CircularException

/// formulareturnnamenameSet
///nameA1B1A1 * 2C1B1 + A1{A1B1C1}

///

public abstract ISet SetCellContents(String name, Formula formula);

///

/// namenullArgumentNullException.

/// namenameInvalidNameException.

///

A13B1A1*A1 C1B1+A1D1B1-C1.A1B1C1

///

protected abstract IEnumerable GetDirectDependents(String name);

///

///

///

protected IEnumerable GetCellsToRecalculate(ISet names)

{

LinkedList changed = new LinkedList ();

HashSet visited = new HashSet ();

foreach (String name in names)

{

if (!visited.Contains(name))

{

Visit(name, name, visited, changed);

}

}

return changed;

}

///

///GetCellsToRecalculate

///

protected IEnumerable GetCellsToRecalculate(String name)

{

return GetCellsToRecalculate(new HashSet () { name });

}

///

/// A helper for the GetCellsToRecalculate method.

///

private void Visit(String start, String name, ISet visited, LinkedList modified)

{

visited.Add(name);

foreach (String n in GetDirectDependents(name))

{

if (n.Equals(start))

{

throw new CircularException();

}

else if (!visited.Contains(n))

{

Visit(start, n, visited, modified);

}

}

modified.AddFirst(name);

}

}

}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Using System;
$25