-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommodities.cs
45 lines (42 loc) · 1.28 KB
/
Commodities.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
namespace econrpg
{
public class Commodities
{
static List<Commodity> commodities = new List<Commodity>();
static public void startCommodities(String[] namesList)
{
foreach (String name in namesList)
{
commodities.Add(new Commodity(name));
}
}
static public Commodity? getOneByName(String name)
{
try
{
Commodity foundCommodity = commodities.Find(item => item.getName() == name);
foundCommodity.getId();
return foundCommodity;
}
catch (NullReferenceException e)
{
Console.WriteLine($"[Error]: Commodity with name {name} was not found");
throw e;
}
}
static public Commodity getOneById(int id)
{
try
{
Commodity foundCommodity = commodities.Find(item => item.getId() == id);
foundCommodity.getId();
return foundCommodity;
}
catch (NullReferenceException e)
{
Console.WriteLine($"[Error]: Commodity with id {id} was not found");
throw e;
}
}
}
}