-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (34 loc) · 1.1 KB
/
Program.cs
File metadata and controls
45 lines (34 loc) · 1.1 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
40
41
42
43
44
45
using System;
using System.Threading;
using Observable.obervable;
namespace Observable
{
class Program
{
static void Main()
{
//Empresas
var empresaNaBolsa = new BolsaSubject("Magazine Luiza", 26.50);
var empresa2NaBolsa = new BolsaSubject("Usiminas", 21.0);
//investidores
var investidor1 = new InvestidorObservable("Filipe Ferreira");
var investidor2 = new InvestidorObservable("Laura Ferreira");
empresaNaBolsa.Attach(investidor1);
empresaNaBolsa.Attach(investidor2);
empresa2NaBolsa.Attach(investidor2);
for(int i =0; i < 100; i++){
empresaNaBolsa.ValueState = NewValue();
empresa2NaBolsa.ValueState = NewValue();
if(i > 3){
empresaNaBolsa.Detach(investidor2);
}
}
Console.ReadKey();
}
static double NewValue(){
Thread.Sleep(3000);
var random = new Random();
return random.Next(20, 25);
}
}
}