Change CommandPattern from console to library

Remove Random from StockSchedule
This commit is contained in:
Petrutiu Mihai
2016-06-23 09:02:08 +03:00
parent e1fd32ab8f
commit ae4beae6c2
3 changed files with 8 additions and 18 deletions

View File

@@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CommandPattern
{
public class Program
{
public static void Main(string[] args)
{
}
}
}

View File

@@ -6,17 +6,24 @@ namespace CommandPattern.StocksExample
public class StockSchedule
{
TimeSpan openingTime;
TimeSpan closingTime;
public StockSchedule()
{
CheckForOpeningOfStockExchange();
openingTime = new TimeSpan(9, 0, 0);
closingTime = new TimeSpan(17, 0, 0);
}
public event EventHandler StockExchangedOpened;
public bool IsStockOpen()
{
return new Random().NextDouble() > 0.5;
var timeOfDay = DateTime.Now.TimeOfDay;
if(timeOfDay.CompareTo(openingTime) > 0 && timeOfDay.CompareTo(closingTime) < 0)
{
return true;
}
return false;
}
private void OnStockExchangedOpened(object state)

View File

@@ -1,8 +1,5 @@
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {