diff --git a/Casino/Blackjack.js b/Casino/Blackjack.js new file mode 100644 index 00000000..a1d10f9e --- /dev/null +++ b/Casino/Blackjack.js @@ -0,0 +1,107 @@ +"use strict"; +exports.__esModule = true; +var CardFactory_1 = require("./CardFactory"); +var Dealer_1 = require("./Dealer"); +var Blackjack = /** @class */ (function () { + function Blackjack(entryPlayer) { + this.betAmount = 0; + this.deck = CardFactory_1.CardFactory.createStandardDeck(); + this.dealer = new Dealer_1["default"](); + this.player = entryPlayer; + } + Blackjack.prototype.startGame = function () { + }; + Blackjack.prototype.outOfMoneyCheck = function () { + if (this.player.getBalance() < 10) { + return true; + } + return false; + }; + Blackjack.prototype.preGameReset = function () { + this.player.setHand([]); + this.dealer.setHand([]); + this.player.setCanHit(true); + this.setBetAmount(0); + }; + Blackjack.prototype.getBetAmount = function () { + return this.betAmount; + }; + Blackjack.prototype.setBetAmount = function (amount) { + this.betAmount = amount; + }; + Blackjack.prototype.runTurn = function () { + for (var i = 0; i < this.player.getHand.length; i++) { + //Tell them what they have + } + this.setBetAmount(10); + }; + Blackjack.prototype.deal = function () { + var temp = this.deck.privateCards[0]; + this.player.addToHand(temp); + this.deck.privateCards.shift(); + }; + Blackjack.prototype.dealToDealer = function () { + var temp = this.deck.privateCards[0]; + this.dealer.addToHand(temp); + this.deck.privateCards.shift(); + }; + Blackjack.prototype.initialHand = function () { + this.deal; + this.deal; + this.dealToDealer; + this.dealToDealer; + }; + Blackjack.prototype.bustCheck = function (player) { + var handValue = player.getHandValue(); + if (handValue > 21) { + return true; + } + return false; + }; + Blackjack.prototype.dealerHitCheck = function () { + if (this.dealer.getHandValue() > 16) { + return false; + } + return true; + }; + Blackjack.prototype.dealerTurn = function () { + while (this.dealerHitCheck()) { + this.dealToDealer(); + } + //tell them what the dealer has + }; + Blackjack.prototype.winCheck = function () { + var playerHand = this.player.getHandValue(); + if (playerHand == 21 || playerHand > this.dealer.getHandValue()) { + return true; + } + return false; + }; + Blackjack.prototype.playerHitOption = function () { + var hitOrNot = this.runPlayerHit(); + if (hitOrNot != null) { + return hitOrNot; + } + return hitOrNot; + }; + Blackjack.prototype.runPlayerHit = function () { + while (this.player.canIHit()) { + if (this.player.getHandValue() > 21) { + //tell them they bust + break; + } + var hit; + if (hit) { + return true; + } + this.player.setCanHit(false); + return false; + } + }; + Blackjack.prototype.setPlaying = function (isPlaying) { + this.isPlaying = isPlaying; + }; + Blackjack.prototype.endGame = function () { + }; + return Blackjack; +}()); diff --git a/Casino/Blackjack.ts b/Casino/Blackjack.ts new file mode 100644 index 00000000..298e9888 --- /dev/null +++ b/Casino/Blackjack.ts @@ -0,0 +1,138 @@ +import {Cards} from "./Card"; +import {CardFactory} from "./CardFactory"; +import {CardShuffler} from "./CardShuffler"; +import Deck from "./Deck"; +import BlackjackPlayer from "./BlackjackPlayer"; +import Game from "./Game"; +import Dealer from "./Dealer"; + +class Blackjack implements Game { + player: BlackjackPlayer; + deck: Deck; + dealer: Dealer; + isPlaying: Boolean; + betAmount: number = 0; + + constructor(entryPlayer: BlackjackPlayer) { + this.deck = CardFactory.createStandardDeck(); + this.dealer = new Dealer(); + this.player = entryPlayer; + } + + startGame() { + } + + outOfMoneyCheck(): Boolean { + if(this.player.getBalance() < 10) { + return true; + } + return false; + } + + preGameReset() { + this.player.setHand([]); + this.dealer.setHand([]); + this.player.setCanHit(true); + this.setBetAmount(0); + + } + + getBetAmount(): number { + return this.betAmount; + } + + setBetAmount(amount: number) { + this.betAmount = amount; + } + + runTurn() { + for(var i = 0; i < this.player.getHand.length; i++) { + //Tell them what they have + } + this.setBetAmount(10); + } + + deal() { + var temp: Cards = this.deck.privateCards[0]; + this.player.addToHand(temp); + this.deck.privateCards.shift(); + } + + dealToDealer() { + var temp: Cards = this.deck.privateCards[0]; + this.dealer.addToHand(temp); + this.deck.privateCards.shift(); + } + + initialHand() { + this.deal; + this.deal; + this.dealToDealer; + this.dealToDealer; + } + + bustCheck(player: BlackjackPlayer): Boolean { + var handValue: number = player.getHandValue(); + if(handValue > 21) { + return true; + } + return false; + } + + dealerHitCheck(): Boolean { + if(this.dealer.getHandValue() > 16) { + return false; + } + return true; + } + + dealerTurn() { + while(this.dealerHitCheck()) { + this.dealToDealer(); + } + //tell them what the dealer has + } + + winCheck(): Boolean { + var playerHand: number = this.player.getHandValue(); + if(playerHand == 21 || playerHand > this.dealer.getHandValue()) { + return true; + } + return false; + } + + playerHitOption(): Boolean { + var hitOrNot: Boolean = this.runPlayerHit(); + if(hitOrNot != null) { + return hitOrNot; + } + return hitOrNot; + } + + runPlayerHit(): Boolean { + while(this.player.canIHit()) { + if(this.player.getHandValue() > 21) { + //tell them they bust + break; + } + var hit: Boolean; + + if(hit) { + return true + } + this.player.setCanHit(false); + return false + } + } + + setPlaying(isPlaying: Boolean) { + this.isPlaying = isPlaying; + } + + + + + endGame() { + + } +} \ No newline at end of file diff --git a/Casino/BlackjackPlayer.js b/Casino/BlackjackPlayer.js new file mode 100644 index 00000000..3cc58d4d --- /dev/null +++ b/Casino/BlackjackPlayer.js @@ -0,0 +1,63 @@ +"use strict"; +exports.__esModule = true; +var Wallet_1 = require("./Wallet"); +var BlackjackPlayer = /** @class */ (function () { + function BlackjackPlayer(firstName, lastName, balance) { + this.firstName = firstName; + this.lastName = lastName; + this.wallet = new Wallet_1["default"](balance); + } + BlackjackPlayer.prototype.getName = function () { + return this.firstName + " " + this.lastName; + }; + BlackjackPlayer.prototype.setName = function (firstName, lastName) { + this.firstName = firstName; + this.lastName = lastName; + }; + BlackjackPlayer.prototype.getBalance = function () { + return this.wallet.getBalance(); + }; + BlackjackPlayer.prototype.setHand = function (hand) { + this.hand = hand; + }; + BlackjackPlayer.prototype.addToHand = function (card) { + this.hand.push(card); + }; + BlackjackPlayer.prototype.getHand = function () { + return this.hand; + }; + BlackjackPlayer.prototype.canIHit = function () { + return this.canHit; + }; + BlackjackPlayer.prototype.setCanHit = function (bool) { + this.canHit = bool; + }; + BlackjackPlayer.prototype.getHandValue = function () { + var handValue = 0; + var aceCounter = 0; + for (var i = 0; i < this.hand.length; i++) { + if (this.hand[i].getRank() == 1) { + aceCounter += 1; + handValue += 11; + } + else if (this.hand[i].getRank() > 9) { + handValue += 10; + } + else { + handValue += this.hand[i].getRank(); + } + if (aceCounter > 0 && handValue > 21) { + handValue -= 10; + } + } + return handValue; + }; + BlackjackPlayer.prototype.payoutWin = function (amount) { + this.wallet.add(amount); + }; + BlackjackPlayer.prototype.payoutLoss = function (amount) { + this.wallet.subtract(amount); + }; + return BlackjackPlayer; +}()); +exports["default"] = BlackjackPlayer; diff --git a/Casino/BlackjackPlayer.ts b/Casino/BlackjackPlayer.ts new file mode 100644 index 00000000..c953e981 --- /dev/null +++ b/Casino/BlackjackPlayer.ts @@ -0,0 +1,84 @@ +import {Cards} from "./Card"; +import {CardFactory} from "./CardFactory"; +import {CardShuffler} from "./CardShuffler"; +import Deck from "./Deck"; +import Wallet from "./Wallet"; + +class BlackjackPlayer{ +private hand: Array; +private canHit: Boolean; +protected firstName: string; +protected lastName: string; +protected wallet: Wallet; + + constructor(firstName: string, lastName: string, balance: number) { + this.firstName = firstName; + this.lastName = lastName; + this.wallet = new Wallet(balance); + } + + getName(): string { + return this.firstName + " " + this.lastName; + } + + setName(firstName: string, lastName: string) { + this.firstName = firstName; + this.lastName = lastName; + } + + getBalance(): number { + return this.wallet.getBalance(); + } + + setHand(hand: Array) { + this.hand = hand; + } + + addToHand(card: Cards) { + this.hand.push(card); + } + + getHand(): Array { + return this.hand; + } + + canIHit(): Boolean { + return this.canHit; + } + + setCanHit(bool: Boolean) { + this.canHit = bool; + } + + getHandValue(): number { + var handValue: number = 0; + var aceCounter: number = 0; + + for(var i = 0; i < this.hand.length; i++) { + if(this.hand[i].getRank() == 1) { + aceCounter += 1; + handValue += 11; + } else if(this.hand[i].getRank() > 9) { + handValue += 10; + } else { + handValue += this.hand[i].getRank(); + } + + if(aceCounter > 0 && handValue > 21) { + handValue -= 10; + } + } + return handValue; + } + + payoutWin(amount: number) { + this.wallet.add(amount); + } + + payoutLoss(amount: number) { + this.wallet.subtract(amount); + } + +} + +export default BlackjackPlayer; \ No newline at end of file diff --git a/Casino/Card.js b/Casino/Card.js new file mode 100644 index 00000000..3c56fd37 --- /dev/null +++ b/Casino/Card.js @@ -0,0 +1,43 @@ +"use strict"; +exports.__esModule = true; +var PictureCard; +(function (PictureCard) { + PictureCard[PictureCard["Ace"] = 0] = "Ace"; + PictureCard[PictureCard["Jack"] = 1] = "Jack"; + PictureCard[PictureCard["Queen"] = 2] = "Queen"; + PictureCard[PictureCard["King"] = 3] = "King"; +})(PictureCard || (PictureCard = {})); +exports.PictureCard = PictureCard; +var Suit; +(function (Suit) { + Suit[Suit["Hearts"] = 0] = "Hearts"; + Suit[Suit["Diamonds"] = 1] = "Diamonds"; + Suit[Suit["Spades"] = 2] = "Spades"; + Suit[Suit["Clubs"] = 3] = "Clubs"; +})(Suit || (Suit = {})); +exports.Suit = Suit; +var Cards = /** @class */ (function () { + function Cards(rank, suit) { + this.isPictureCard = function () { + return this.rank > 10 || this.rank === 1; + }; + if (rank > 0 && rank < 14) { + this.rank = rank; + } + else { + throw new RangeError("Card is outside of normal deck range."); + } + this.suit = suit; + } + Cards.prototype.getRank = function () { + return this.rank; + }; + Cards.prototype.getSuit = function () { + return this.suit; + }; + Cards.prototype.toJSObject = function () { + return { suite: Suit[this.suit], rank: this.isPictureCard() ? PictureCard[this.rank] : this.rank.toString() }; + }; + return Cards; +}()); +exports.Cards = Cards; diff --git a/Casino/Card.ts b/Casino/Card.ts new file mode 100644 index 00000000..4d18b4e1 --- /dev/null +++ b/Casino/Card.ts @@ -0,0 +1,43 @@ +enum PictureCard { + Ace, + Jack, + Queen, + King +} + +enum Suit { + Hearts, + Diamonds, + Spades, + Clubs +} + +class Cards { + rank: number; + suit: Suit; + isPictureCard = function(): boolean { + return this.rank > 10 || this.rank === 1; + } + + constructor(rank: number, suit: Suit) { + if(rank > 0 && rank < 14) { + this.rank = rank; + } else { + throw new RangeError("Card is outside of normal deck range."); + } + this.suit = suit; + } + + getRank(): number { + return this.rank; + } + + getSuit(): Suit { + return this.suit; + } + + toJSObject(): any { + return {suite: Suit[this.suit], rank: this.isPictureCard() ? PictureCard[this.rank] : this.rank.toString()}; + } +} +export {Cards, PictureCard, Suit}; \ No newline at end of file diff --git a/Casino/CardFactory.js b/Casino/CardFactory.js new file mode 100644 index 00000000..7303986a --- /dev/null +++ b/Casino/CardFactory.js @@ -0,0 +1,26 @@ +"use strict"; +exports.__esModule = true; +var Deck_1 = require("./Deck"); +var Card_1 = require("./Card"); +var CardShuffler_1 = require("./CardShuffler"); +var buildStandardDeck = function () { + var cards = new Array(); + for (var suit in Card_1.Suit) { + if (!isNaN(parseInt(suit))) { + var suitAsNumber = parseInt(suit); + for (var rank = 1; rank < 14; rank++) { + cards.push(new Card_1.Cards(rank, suitAsNumber)); + } + } + } + return cards; +}; +var CardFactory = /** @class */ (function () { + function CardFactory() { + } + CardFactory.createStandardDeck = function () { + return new Deck_1["default"](buildStandardDeck(), new CardShuffler_1.CardShuffler()); + }; + return CardFactory; +}()); +exports.CardFactory = CardFactory; diff --git a/Casino/CardFactory.ts b/Casino/CardFactory.ts new file mode 100644 index 00000000..9798de78 --- /dev/null +++ b/Casino/CardFactory.ts @@ -0,0 +1,23 @@ +import Deck from "./Deck"; +import {Cards, Suit} from './Card'; +import {CardShuffler, Shuffler} from "./CardShuffler"; + +let buildStandardDeck = function(): Cards[] { + let cards = new Array(); + + for(let suit in Suit) { + if(!isNaN(parseInt(suit))) { + let suitAsNumber: number = parseInt(suit); + for(let rank = 1; rank < 14; rank++) { + cards.push(new Cards(rank, suitAsNumber)); + } + } + } + return cards; +}; + +export class CardFactory { + public static createStandardDeck(): Deck { + return new Deck(buildStandardDeck(), new CardShuffler()); + } +} \ No newline at end of file diff --git a/Casino/CardShuffler.js b/Casino/CardShuffler.js new file mode 100644 index 00000000..2b4cd05c --- /dev/null +++ b/Casino/CardShuffler.js @@ -0,0 +1,18 @@ +"use strict"; +exports.__esModule = true; +var CardShuffler = /** @class */ (function () { + function CardShuffler() { + } + CardShuffler.prototype.shuffle = function (inputCards) { + var shuffledDeck = []; + var n = inputCards.length; + var i; + while (n) { + i = Math.floor(Math.random() * n--); + shuffledDeck.push(inputCards.splice(i, 1)[0]); + } + return shuffledDeck.slice(0); + }; + return CardShuffler; +}()); +exports.CardShuffler = CardShuffler; diff --git a/Casino/CardShuffler.ts b/Casino/CardShuffler.ts new file mode 100644 index 00000000..4464c2e4 --- /dev/null +++ b/Casino/CardShuffler.ts @@ -0,0 +1,20 @@ +import {Cards, Suit} from "./card"; + +export interface Shuffler { + shuffle(inputCards: Cards[]): Cards[]; +} + +export class CardShuffler implements Shuffler { + shuffle(inputCards: Cards[]): Cards[] { + var shuffledDeck: Cards[] = []; + var n: number = inputCards.length; + var i: number; + + while(n) { + i = Math.floor(Math.random() * n--); + shuffledDeck.push(inputCards.splice(i, 1)[0]); + } + return shuffledDeck.slice(0); + } + +} \ No newline at end of file diff --git a/Casino/Casino.js b/Casino/Casino.js new file mode 100644 index 00000000..17212f8d --- /dev/null +++ b/Casino/Casino.js @@ -0,0 +1,22 @@ +"use strict"; +exports.__esModule = true; +var BlackjackPlayer_1 = require("./BlackjackPlayer"); +var Casino = /** @class */ (function () { + function Casino() { + this.isPlaying = true; + this.displayElement = document.getElementById("display"); + this.submitButton = document.getElementById("submitButton"); + } + Casino.prototype.start = function () { + var _this = this; + var firstName = document.getElementById("first").innerHTML; + var lastName = document.getElementById("last").innerHTML; + var balance = parseInt(document.getElementById("balance").innerHTML); + this.submitButton.addEventListener("click", function (e) { return _this.setupUserProfile(firstName, lastName, balance); }, { once: true }); + }; + Casino.prototype.setupUserProfile = function (firstName, lastName, balance) { + this.player = new BlackjackPlayer_1["default"](firstName, lastName, balance); + this.displayElement.innerHTML += "Hello " + this.player.getName(); + }; + return Casino; +}()); diff --git a/Casino/Casino.ts b/Casino/Casino.ts new file mode 100644 index 00000000..30ba91bd --- /dev/null +++ b/Casino/Casino.ts @@ -0,0 +1,19 @@ +import BlackjackPlayer from "./BlackjackPlayer"; + +class Casino { + isPlaying: Boolean = true; + player: BlackjackPlayer; + displayElement: HTMLElement = document.getElementById("display"); + submitButton: HTMLElement = document.getElementById("submitButton"); + + start() { + var firstName: string = document.getElementById("first").innerHTML; + var lastName: string = document.getElementById("last").innerHTML; + var balance: number = parseInt(document.getElementById("balance").innerHTML); + this.submitButton.addEventListener("click", (e: Event) => this.setupUserProfile(firstName, lastName, balance), {once:true}); + } + setupUserProfile(firstName: string, lastName: string, balance: number) { + this.player = new BlackjackPlayer(firstName, lastName, balance); + this.displayElement.innerHTML += "Hello " + this.player.getName(); + } +} \ No newline at end of file diff --git a/Casino/Dealer.js b/Casino/Dealer.js new file mode 100644 index 00000000..4099f6ae --- /dev/null +++ b/Casino/Dealer.js @@ -0,0 +1,44 @@ +"use strict"; +exports.__esModule = true; +var Dealer = /** @class */ (function () { + function Dealer() { + this.hand = new Array(); + } + Dealer.prototype.setHand = function (hand) { + this.hand = hand; + }; + Dealer.prototype.getHand = function () { + return this.hand; + }; + Dealer.prototype.addToHand = function (card) { + this.hand.push(card); + }; + Dealer.prototype.getHandValue = function () { + var handValue = 0; + var aceCounter = 0; + for (var i = 0; i < this.hand.length; i++) { + if (this.hand[i].getRank() == 1) { + aceCounter += 1; + handValue += 11; + } + else if (this.hand[i].getRank() > 9) { + handValue += 10; + } + else { + handValue += this.hand[i].getRank(); + } + if (aceCounter > 0 && handValue > 21) { + handValue -= 10; + } + } + return handValue; + }; + Dealer.prototype.canHit = function () { + if (this.getHandValue() < 17) { + return true; + } + return false; + }; + return Dealer; +}()); +exports["default"] = Dealer; diff --git a/Casino/Dealer.ts b/Casino/Dealer.ts new file mode 100644 index 00000000..5b708116 --- /dev/null +++ b/Casino/Dealer.ts @@ -0,0 +1,54 @@ +import {Cards} from "./Card"; +import {CardFactory} from "./CardFactory"; +import {CardShuffler} from "./CardShuffler"; +import Deck from "./Deck"; + +class Dealer { + hand: Array; + + constructor() { + this.hand = new Array(); + } + + setHand(hand: Array) { + this.hand = hand; + } + + getHand(): Array { + return this.hand; + } + + addToHand(card: Cards) { + this.hand.push(card); + } + + getHandValue(): number { + var handValue: number = 0; + var aceCounter: number = 0; + + for(var i = 0; i < this.hand.length; i++) { + if(this.hand[i].getRank() == 1) { + aceCounter += 1; + handValue += 11; + } else if(this.hand[i].getRank() > 9) { + handValue += 10; + } else { + handValue += this.hand[i].getRank(); + } + + if(aceCounter > 0 && handValue > 21) { + handValue -= 10; + } + } + return handValue; + } + + canHit(): Boolean { + if(this.getHandValue() < 17) { + return true; + } + return false; + } +} + +export default Dealer; \ No newline at end of file diff --git a/Casino/Deck.js b/Casino/Deck.js new file mode 100644 index 00000000..55a700a4 --- /dev/null +++ b/Casino/Deck.js @@ -0,0 +1,63 @@ +"use strict"; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var privateCards; +var getNextCard = function () { + var card; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!(privateCards.length > 0)) return [3 /*break*/, 2]; + card = privateCards.splice(0, 1)[0]; + return [4 /*yield*/, card]; + case 1: + _a.sent(); + return [3 /*break*/, 0]; + case 2: return [2 /*return*/]; + } + }); +}; +var Deck = /** @class */ (function () { + function Deck(cards, cardShuffler) { + privateCards = cards.slice(0); + this.cardShuffler = cardShuffler; + } + Deck.prototype.shuffle = function () { + var shuffledDeck = this.cardShuffler.shuffle(privateCards); + privateCards = shuffledDeck.slice(0); + }; + Deck.prototype.getCards = function () { + return privateCards; + }; + Deck.prototype.dealCard = function () { + return privateCards[0]; + }; + return Deck; +}()); +exports["default"] = Deck; diff --git a/Casino/Deck.ts b/Casino/Deck.ts new file mode 100644 index 00000000..61ec2290 --- /dev/null +++ b/Casino/Deck.ts @@ -0,0 +1,41 @@ +import {Cards, Suit} from "./card"; +import {CardShuffler} from "./CardShuffler"; + +interface DeckofCards { + privateCards: Cards[]; + shuffle(): void; + dealCard(): Cards; +} + +let privateCards: Cards[]; + +let getNextCard = function*() { + while(privateCards.length > 0) { + let card: Cards = privateCards.splice(0, 1)[0] + yield card; + } +}; + +class Deck implements DeckofCards{ + cardShuffler: CardShuffler; + privateCards: Cards[]; + + constructor(cards: Cards[], cardShuffler: CardShuffler) { + privateCards = cards.slice(0); + this.cardShuffler = cardShuffler; + } + + shuffle() { + let shuffledDeck = this.cardShuffler.shuffle(privateCards); + privateCards = shuffledDeck.slice(0); + } + + getCards(): Cards[] { + return privateCards; + } + + dealCard(): Cards { + return privateCards[0]; + } +} +export default Deck; \ No newline at end of file diff --git a/Casino/Game.js b/Casino/Game.js new file mode 100644 index 00000000..0e345787 --- /dev/null +++ b/Casino/Game.js @@ -0,0 +1,2 @@ +"use strict"; +exports.__esModule = true; diff --git a/Casino/Game.ts b/Casino/Game.ts new file mode 100644 index 00000000..8b94b1df --- /dev/null +++ b/Casino/Game.ts @@ -0,0 +1,7 @@ +interface Game { + + startGame(); + endGame(); + +} +export default Game; \ No newline at end of file diff --git a/Casino/Wallet.js b/Casino/Wallet.js new file mode 100644 index 00000000..8c73d23a --- /dev/null +++ b/Casino/Wallet.js @@ -0,0 +1,18 @@ +"use strict"; +exports.__esModule = true; +var Wallet = /** @class */ (function () { + function Wallet(balance) { + this.balance = balance; + } + Wallet.prototype.getBalance = function () { + return this.balance; + }; + Wallet.prototype.add = function (amount) { + this.balance += amount; + }; + Wallet.prototype.subtract = function (amount) { + this.balance -= amount; + }; + return Wallet; +}()); +exports["default"] = Wallet; diff --git a/Casino/Wallet.ts b/Casino/Wallet.ts new file mode 100644 index 00000000..0ec42736 --- /dev/null +++ b/Casino/Wallet.ts @@ -0,0 +1,20 @@ +class Wallet { + private balance: number; + + constructor(balance: number) { + this.balance = balance; + } + + getBalance(): number { + return this.balance; + } + + add(amount: number) { + this.balance += amount; + } + + subtract(amount: number) { + this.balance -= amount; + } +} +export default Wallet; \ No newline at end of file