-
Notifications
You must be signed in to change notification settings - Fork 0
/
Explicit
37 lines (34 loc) · 1.07 KB
/
Explicit
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
interface IEnglishDimensions
{
float Length();
float Width();
}
interface IMetricDimensions
{
float Length();
float Width();
}
class Box : IEnglishDimensions, IMetricDimensions
{
float lengthInches;
float widthInches;
public Box(float lengthInches, float widthInches)
{
this.lengthInches = lengthInches;
this.widthInches = widthInches;
}
float IEnglishDimensions.Length() => lengthInches;
float IEnglishDimensions.Width() => widthInches;
float IMetricDimensions.Length() => lengthInches * 2.54f;
float IMetricDimensions.Width() => widthInches * 2.54f;
static void Main()
{
Box box1 = new Box(30.0f, 20.0f);
IEnglishDimensions eDimensions = box1;
IMetricDimensions mDimensions = box1;
System.Console.WriteLine("Length(in): {0}", eDimensions.Length());
System.Console.WriteLine("Width (in): {0}", eDimensions.Width());
System.Console.WriteLine("Length(cm): {0}", mDimensions.Length());
System.Console.WriteLine("Width (cm): {0}", mDimensions.Width());
}
}