Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ЗД12 Бой с Боссом.
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp3
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Deck deck = new Deck();
- deck.HandOutCards(10);
- }
- }
- class Card
- {
- public string Name { get; private set; }
- public string Suit { get; private set; }
- public Card( string name, string suit)
- {
- Name = name;
- Suit = suit;
- }
- }
- class Deck
- {
- private int _size;
- private List<Card> _deck;
- private string[] _suits = { "Черва", "Крести", "Пика", "Бубна" };
- private string[] _names = { "2", "3", "4", "5", "6", "7", "8", "9", "10", "Валет", "Дама", "Король", "Туз" };
- private Random _random;
- public Deck()
- {
- _size = 56;
- _deck = new List<Card>(_size);
- MakeDeck();
- _random = new Random();
- }
- private void MakeDeck()
- {
- for (int index = 0; index < _suits.Length; index++)
- {
- for (int subIndex = 0; subIndex < _names.Length; subIndex++)
- {
- _deck.Add(new Card(_names[subIndex], _suits[index]));
- }
- }
- }
- public void PrintDeck()
- {
- foreach (var elemet in _deck)
- {
- Console.WriteLine(elemet.Name +" "+ elemet.Suit);
- }
- }
- public void HandOutCards(int count)
- {
- for (int index = 0; index < count; index++)
- {
- int card = _random.Next(0, _size);
- Console.WriteLine(_deck[card].Name +" "+ _deck[card].Suit);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement