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 public class StockSchedule
{ {
TimeSpan openingTime; TimeSpan openingTime;
TimeSpan closingTime;
public StockSchedule() public StockSchedule()
{ {
CheckForOpeningOfStockExchange(); CheckForOpeningOfStockExchange();
openingTime = new TimeSpan(9, 0, 0); openingTime = new TimeSpan(9, 0, 0);
closingTime = new TimeSpan(17, 0, 0);
} }
public event EventHandler StockExchangedOpened; public event EventHandler StockExchangedOpened;
public bool IsStockOpen() 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) private void OnStockExchangedOpened(object state)

View File

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