-
Notifications
You must be signed in to change notification settings - Fork 0
/
Item.cs
56 lines (55 loc) · 1.61 KB
/
Item.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
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WpfApplication1
{
public class Item
{
public event EventHandler NameChanged;
private void OnNameChanged()
{
if (NameChanged != null)
NameChanged(this, EventArgs.Empty);
}
public event EventHandler WeightPoundsChanged;
private void OnWeightPoundsChanged()
{
if (WeightPoundsChanged != null)
WeightPoundsChanged(this, EventArgs.Empty);
}
public event EventHandler GoldValueChanged;
private void OnGoldValueChanged()
{
if (GoldValueChanged != null)
GoldValueChanged(this, EventArgs.Empty);
}
string name;
float goldValue;
float weight;
public string Name { get { return name; } set { name = value; OnNameChanged(); } }
public float GoldValue { get { return goldValue; } set { goldValue = value; OnGoldValueChanged(); } }
public float WeightPounds
{
get { return weight; }
set
{
weight = value;
OnWeightPoundsChanged();
}
}
public float WeightKilos
{
get { return weight * 0.45359f; }
set { weight = value / 0.45359f;
OnWeightPoundsChanged();
}
}
public Item(string name, float goldValue, float weight)
{
this.name = name;
this.goldValue = goldValue;
this.weight = weight;
}
}
}