Skip to content

submit button works #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added app/Player.js
Empty file.
Empty file added app/Player.ts
Empty file.
Empty file added app/PlayerInterface.js
Empty file.
6 changes: 6 additions & 0 deletions app/PlayerInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface PlayerInterface
{
profileName : string;
id : string;
name : string;
}
8 changes: 8 additions & 0 deletions app/Profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var Profile = /** @class */ (function () {
function Profile(id, name, balance) {
this.balance = balance;
this.id = id;
this.name = name;
}
return Profile;
}());
13 changes: 13 additions & 0 deletions app/Profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Profile
{
id : number;
name : string;
balance : number;

constructor(id : number, name : string, balance : number)
{
this.balance = balance;
this.id = id;
this.name = name;
}
}
106 changes: 106 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
var UserInterface = /** @class */ (function () {
function UserInterface() {
var _this = this;
this.userInput = document.getElementById('user_input');
this.window = document.getElementById('display');
this.button = document.getElementById('submit');
this.button.addEventListener("click", function (e) { _this._lastInput = _this.userInput.value; });
this.button.addEventListener("click", function (e) { return console.log(_this._lastInput); });
this.button.addEventListener("click", function (e) { _this.userInput.value = ''; });
}
UserInterface.prototype.display = function (input) {
this.window.innerText += input + '\n';
};
UserInterface.prototype.clear = function () {
this.window.innerText = '';
};
UserInterface.prototype.lastInput = function () {
return this._lastInput;
};
UserInterface.prototype.start = function () {
var _this = this;
this.display("Choose a game by entering it in the text field below and then click submit");
this.button.addEventListener("click", function (e) { return _this.chooseGame(); });
};
UserInterface.prototype.chooseGame = function () {
if (this.lastInput() === "Blackjack" || this.lastInput() === "blackjack") {
this.clear();
this.display("Ok, get ready to lose son!");
}
else {
this.clear();
this.display("Good, you were gonna lose anyway!");
}
};
return UserInterface;
}());
var MathOps = /** @class */ (function () {
function MathOps() {
}
MathOps.sum = function (number1, number2) {
return (number1 + number2);
};
return MathOps;
}());
var SuitString;
(function (SuitString) {
SuitString["CLUBS"] = "clubs";
SuitString["DIAMONDS"] = "diamonds";
SuitString["HEARTS"] = "hearts";
SuitString["SPADES"] = "spades";
})(SuitString || (SuitString = {}));
var SuitSymbol;
(function (SuitSymbol) {
SuitSymbol["CLUBS"] = "\u2663";
SuitSymbol["DIAMONDS"] = "\u2666";
SuitSymbol["HEARTS"] = "\u2665";
SuitSymbol["SPADES"] = "\u2660";
})(SuitSymbol || (SuitSymbol = {}));
var RankNumber;
(function (RankNumber) {
RankNumber[RankNumber["DEUCE"] = 2] = "DEUCE";
RankNumber[RankNumber["THREE"] = 3] = "THREE";
RankNumber[RankNumber["FOUR"] = 4] = "FOUR";
RankNumber[RankNumber["FIVE"] = 5] = "FIVE";
RankNumber[RankNumber["SIX"] = 6] = "SIX";
RankNumber[RankNumber["SEVEN"] = 7] = "SEVEN";
RankNumber[RankNumber["EIGHT"] = 8] = "EIGHT";
RankNumber[RankNumber["NINE"] = 9] = "NINE";
RankNumber[RankNumber["TEN"] = 10] = "TEN";
RankNumber[RankNumber["JACK"] = 11] = "JACK";
RankNumber[RankNumber["QUEEN"] = 12] = "QUEEN";
RankNumber[RankNumber["KING"] = 13] = "KING";
RankNumber[RankNumber["ACE"] = 1] = "ACE";
})(RankNumber || (RankNumber = {}));
var RankString;
(function (RankString) {
RankString["DEUCE"] = "2";
RankString["THREE"] = "3";
RankString["FOUR"] = "4";
RankString["FIVE"] = "5";
RankString["SIX"] = "6";
RankString["SEVEN"] = "7";
RankString["EIGHT"] = "8";
RankString["NINE"] = "9";
RankString["TEN"] = "10";
RankString["JACK"] = "J";
RankString["QUEEN"] = "Q";
RankString["KING"] = "K";
RankString["ACE"] = "A";
})(RankString || (RankString = {}));
var Card = /** @class */ (function () {
function Card(suitSymbol, rankNumber, rankString) {
this.suitSymbol = suitSymbol;
this.rankNumber = rankNumber;
this.rankString = rankString;
}
Card.prototype.getSuitSymbol = function () { return this.suitSymbol; };
Card.prototype.getRankNumber = function () { return this.rankNumber; };
Card.prototype.getRankString = function () { return this.rankString; };
Card.prototype.toString = function () {
return this.suitSymbol + this.rankString;
};
return Card;
}());
var UI = new UserInterface;
UI.start();
147 changes: 147 additions & 0 deletions app/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
class UserInterface
{
public userInput: HTMLInputElement = <HTMLInputElement>document.getElementById('user_input');
public window: HTMLDivElement = <HTMLDivElement>document.getElementById('display')
public button: HTMLDivElement = <HTMLDivElement>document.getElementById('submit');
public _lastInput : any;

constructor()
{
this.button.addEventListener("click", (e: Event) => {this._lastInput = this.userInput.value});
this.button.addEventListener("click", (e: Event) => console.log(this._lastInput));
this.button.addEventListener("click", (e:Event) => {this.userInput.value = ''});
}

display(input: string): void
{
this.window.innerText += input + '\n';
}

clear(): void
{
this.window.innerText = '';
}

lastInput(): any
{
return this._lastInput;
}

start()
{
this.display("Choose a game by entering it in the text field below and then click submit");
this.button.addEventListener("click", (e:Event) => this.chooseGame());
}

chooseGame(): void
{
if (this.lastInput() === "Blackjack" || this.lastInput() === "blackjack")
{
this.clear();
this.display("Ok, get ready to lose son!");
}
else
{
this.clear();
this.display("Good, you were gonna lose anyway!");
}
}


}

class MathOps
{
constructor() {}

static sum(number1: number, number2: number): number
{
return (number1 + number2);
}

}

enum SuitString {
CLUBS = "clubs",
DIAMONDS = "diamonds",
HEARTS = "hearts",
SPADES = "spades"
}

enum SuitSymbol
{
CLUBS = "\u2663",
DIAMONDS = "\u2666",
HEARTS = "\u2665",
SPADES = "\u2660"
}

enum RankNumber
{
DEUCE = 2,
THREE = 3,
FOUR = 4,
FIVE = 5,
SIX = 6,
SEVEN = 7,
EIGHT = 8,
NINE = 9,
TEN = 10,
JACK = 11,
QUEEN = 12,
KING = 13,
ACE = 1
}

enum RankString
{
DEUCE = "2",
THREE = "3",
FOUR = "4",
FIVE = "5",
SIX = "6",
SEVEN = "7",
EIGHT = "8",
NINE = "9",
TEN = "10",
JACK = "J",
QUEEN = "Q",
KING = "K",
ACE = "A"
}

class Card
{
private suitSymbol: SuitSymbol;
private rankNumber: RankNumber;
private rankString: RankString;


constructor(suitSymbol : SuitSymbol, rankNumber: RankNumber, rankString: RankString )
{
this.suitSymbol = suitSymbol;
this.rankNumber = rankNumber;
this.rankString = rankString;
}

getSuitSymbol(): string { return this.suitSymbol; }
getRankNumber(): number { return this.rankNumber; }
getRankString(): string { return this.rankString; }

toString(): string
{
return this.suitSymbol + this.rankString;
}


}

let UI: UserInterface = new UserInterface;
UI.start();