forked from the-csharp-academy/CodeReviews.Console.MathGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseOperation.cs
More file actions
39 lines (33 loc) · 1.03 KB
/
Copy pathBaseOperation.cs
File metadata and controls
39 lines (33 loc) · 1.03 KB
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
public abstract class BaseOperation
{
private static readonly Random _Random = new Random();
public int firstNumber {get;}
public int secondNumber {get;}
public abstract int result { get; }
public abstract string operatorSymbol { get; }
public BaseOperation()
{
firstNumber = _Random.Next(1,11);
secondNumber = _Random.Next(1,11);
}
}
public class AdditionOperation : BaseOperation
{
public override string operatorSymbol => "+";
public override int result => firstNumber + secondNumber;
}
public class SubtractionOperation : BaseOperation
{
public override string operatorSymbol => "-";
public override int result => firstNumber - secondNumber;
}
public class MultiplicationOperation : BaseOperation
{
public override string operatorSymbol => "*";
public override int result => firstNumber * secondNumber;
}
public class DivisionOperation : BaseOperation
{
public override string operatorSymbol => "/";
public override int result => firstNumber / secondNumber;
}