Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function () {
- let Suits = {
- CLUBS: "\u2663",
- DIAMONDS: "\u2666",
- HEARTS: "\u2665",
- SPADES: "\u2660"
- };
- let faces = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"];
- class Card {
- constructor(face,suit) {
- this._face = face;
- this._suit = suit;
- if(!(faces).includes(this._face)) {
- throw new Error("ни мой тъка");
- }
- if (!Object.keys(Suits).map(
- k => Suits[k]).includes(this._suit)) {
- throw new Error("ни мой бе тъпак");
- }
- }
- get face() {
- return this._face;
- }
- set face(face) {
- //TODO make validation
- if(!(faces).includes(face)) {
- throw new Error("не дей така");
- }
- return this._face = face;
- }
- get suit() {
- return this._suit;
- }
- set suit(suit) {
- if (!Object.keys(Suits).map(
- k => Suits[k]).includes(suit)) {
- throw new Error("ни мой бе тъпак");
- }
- return this._suit=suit;
- }
- }
- return {Suits,Card}
- }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement