Code Monkey home page Code Monkey logo

deckofcards's Introduction

Object-Oriented Deck of Cards

A Deck of Cards written in TypeScript using Object-Oriented Programming Concept

Card Class

An object of this class is a representation of a playing card and has the following characteristics:

  • Each card has two attributes: Suit and Rank
  • The value of the card can be determined by its suit and rank, and compared using the utility functions isMoreThan() or isLessThan()
    • The compare functions takes in 1 parameter, which is any card, to compare the value of the instance that calls the function and the instance in the paramerter
    • The compare functions will return a boolean according to the value of the two cards

Deck Class

An object of this class resembles a deck of playing cards and has the following characteristics:

  • The constructor takes in an optional parameter cardArr, which is an array of Card Object
    • If cardArr is not specified, the created object will be a deck of 52 cards
    • If cardArr is specified, the array will be converted into a Deck Object
  • Each Deck has these functions:
    • getDeck() : Returns cardArr
    • sortDeck() : Sort the deck (in-place)
    • shuffle() : Shuffle the deck (in-place)
    • draw() : Remove a card from the end of the array and returns it

deckofcards's People

Contributors

pholawat-tle avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.