Advertisement
Layvu

Cons1, Целостность данных

Nov 30th, 2022
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace CardGame
  5. {
  6.     enum Marks
  7.     {
  8.         Peaks,
  9.         Worms,
  10.         Crosses,
  11.         Booby
  12.     }
  13.  
  14.     enum Color
  15.     {
  16.         Red,
  17.         Black
  18.     }
  19.  
  20.     class Card
  21.     {
  22.         private int _score;
  23.         private Marks _mark;
  24.         private Color _color;
  25.  
  26.         public Card(int score, Marks mark, Color color)
  27.         {
  28.             if (score < 0 || score > 14)
  29.                 throw new ArgumentException();
  30.             _score = score;
  31.             _mark = mark;
  32.             _color = color;
  33.         }
  34.  
  35.         public int Score { get; }  
  36.         public Marks Mark { get; }
  37.         public Color Color { get; }
  38.        
  39.     }
  40.  
  41.     static class GameRules
  42.     {
  43.         static private string rules = "";
  44.         static public string Rules
  45.         {
  46.             get { return rules; }
  47.         }
  48.     }
  49.  
  50.     class Player
  51.     {
  52.         public Player(string name) { _name = name; }
  53.  
  54.         public string _name { get; private set; }
  55.         public BoxOfCards CountCardsOnHand { get; set; }
  56.  
  57.         public Card Move(int numberOfCard)
  58.         {
  59.             return CountCardsOnHand.Cards[numberOfCard];
  60.         }
  61.     }
  62.  
  63.     class GameMatch
  64.     {
  65.         public GameMatch(Marks specialCardMark, params Player[] players)
  66.         {
  67.             SpecialCardMark = specialCardMark;
  68.             foreach (var player in players)
  69.                 _players.Add(player);
  70.         }
  71.  
  72.         public readonly Marks SpecialCardMark;
  73.         static List<Player> _players { get; set; }
  74.     }
  75.  
  76.     class Table
  77.     {
  78.         public Deck deck;
  79.  
  80.         public BoxOfCards move1;
  81.         public BoxOfCards move2;
  82.  
  83.         public BoxOfCards beaten;
  84.  
  85.         public Deck Deck { get; }
  86.  
  87.         public BoxOfCards Move1 { get; set; }
  88.         public BoxOfCards Move2 { get; set; }
  89.  
  90.         public BoxOfCards Beaten { get; }
  91.     }
  92.  
  93.     class BoxOfCards
  94.     {
  95.         public List<Card> cards;
  96.         public int countCards { get { return cards.Count; } }
  97.         public List<Card> Cards { get; private set; }
  98.  
  99.         public void AddCards(params Card[] listOfCrds)
  100.         {
  101.             foreach (var i in listOfCrds)
  102.                 cards.Add(i);
  103.         }
  104.     }
  105.  
  106.     class Deck
  107.     {
  108.         public Stack<Card> cards;
  109.         public int CountCards { get { return cards.Count; } }
  110.         public Stack<Card> Cards { get; }
  111.     }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement