-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added constructor and changed return if name not found
- Loading branch information
1 parent
d0621b5
commit 01075d0
Showing
1 changed file
with
13 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |