Repository navigation
Expand file tree
/
Copy pathCardPicker.cs
More file actions
66 lines (52 loc) · 1.68 KB
/
Copy pathCardPicker.cs
File metadata and controls
66 lines (52 loc) · 1.68 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PickACardUI
{
internal class CardPicker
{
private static Random random = new Random();
/// <summary>
/// Escolha um número de cartas e retorne-as
/// </summary>
/// <param name="numberOfCards">O nunmero de cartas para escolher</param>
/// <returns>Um array de srtings com os nomes das cartas</returns>
public static string[] PickSomeCards(int numberOfCards)
{
string[] pickedCards = new string[numberOfCards];
for (int i = 0; i < numberOfCards; i++)
{
pickedCards[i] = $"{RandomValue()} of {RandomSuit()}";
}
return pickedCards;
}
/// <summary>
/// Retorna a figura de carta
/// </summary>
/// <returns>Uma string</returns>
private static string RandomValue()
{
int value = random.Next(1, 14);
switch (value)
{
case 1: return "Ace";
case 11: return "Jack";
case 12: return "Queen";
case 13: return "King";
default: return value.ToString();
}
}
/// <summary>
/// Retorna o naipe conforme a posicao no array
/// </summary>
/// <returns>Uma string do array</returns>
private static string RandomSuit()
{
int value = random.Next(0, 4);
string[] suits = new string[]{"Spades", "Hearts", "Clubs", "Diamonds"};
return suits[value];
}
}
}