Skip to content

Commit

Permalink
added constructor and changed return if name not found
Browse files Browse the repository at this point in the history
  • Loading branch information
jackschonherr authored and Brennan1994 committed Aug 15, 2024
1 parent d0621b5 commit 01075d0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Consequences/Results/Result.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
namespace USACE.HEC.Results;
public class Result
{
private ResultItem[] results;
private ResultItem[] _results;

public Result(ResultItem[] results)
{
_results = results;
}

// retrieve a ResultItem from a Result by name
public ResultItem Fetch(string name)
{
for (int i = 0; i < results.Length; i++)
if (results[i].ResultName == name)
return results[i];
throw new Exception("Name not found.");
for (int i = 0; i < _results.Length; i++)
if (_results[i].ResultName == name)
return _results[i];
// return empty ResultItem if not found
ResultItem item = new ResultItem();
item.ResultName = name;
return item;
}
}

0 comments on commit 01075d0

Please sign in to comment.