-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
74 lines (70 loc) · 2.03 KB
/
Copy pathProgram.cs
File metadata and controls
74 lines (70 loc) · 2.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
namespace inclassLottery;
class Ticket
{
public int[] RegTickets { get; set; }
public int PowerBall { get; set; }
public Ticket(int[] numbers, int powerBall)
{
RegTickets = new int[5];
RegTickets[0] = numbers[0];
RegTickets[1] = numbers[1];
RegTickets[2] = numbers[2];
RegTickets[3] = numbers[3];
RegTickets[4] = numbers[4];
PowerBall = powerBall;
}
public Ticket()
{
RegTickets = new int[5];
for (int i = 0; i < 5; i++)
{
RegTickets[i] = Random.Shared.Next(1, 70);
}
PowerBall = Random.Shared.Next(1, 27);
}
}
class LotteryPeriod
{
public Ticket WinningTicket { get; set; }
public List<Ticket> SoldTickets { get; set; } = new List<Ticket>();
public LotteryPeriod()
{
int[] numbers = new int[5] { 1, 2, 3, 4, 5 };
SetWinningTicket(numbers, 6);
}
public void SetWinningTicket(int[] numbers, int powerBall)
{
WinningTicket = new Ticket(numbers, powerBall);
}
}
class LotteryVendor
{
public LotteryVendor()
{
}
public void SellTickets(LotteryPeriod period, int numberOfTickets)
{
for (int i = 0; i < numberOfTickets; i++)
{
Ticket ticket = new Ticket();
period.SoldTickets.Add(ticket);
}
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, Lets sell 1Million Tickets!");
LotteryPeriod period = new LotteryPeriod();
LotteryVendor vendor = new LotteryVendor();
vendor.SellTickets(period, 1_000_000);
Console.WriteLine("SOLD 1Million Tickets!");
//TODO: 1a) make 3 vendors sell 10M tickets each
// 1b) 3 vendors sell tickets in parallel
// 2) Modify Ticket class to be able to judge a winner level
// 3) Gather statistics on how many winners of each level there are
// 4) Print out the statistics
// AFTER 1-4 is working, try to do (GatherStatistics) with Parallel Programming
}
}