Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Apr 14, 2021
1 parent e6cfb45 commit 487eb01
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { TRIVIA } from "types";
import { getUserInput, printQuestion } from "./mod.ts";

export async function askTriviaQuestion(
selectedTrivia: TRIVIA,
): Promise<void> {
printQuestion(selectedTrivia.question);

await getUserInput();

console.log("The correct answer is:", selectedTrivia.correctAnswer);

console.log("Source:", selectedTrivia.source.name, "\n");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { SOURCE } from "types";

export const generateTVSource = (name: string): SOURCE => ({
name,
mediaType: "Television",
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { readLines } from "std/io/mod.ts";
import { printQuestion } from "./mod.ts";

export const getNumericInput = (): Promise<number> => Promise.resolve(4);

export async function getUserInput(): Promise<string> {
printQuestion("What would you like to enter");

const reader = readLines(Deno.stdin);

return (await reader.next()).value;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function printQuestion(question: string): void {
console.log(question, "?????");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./ask_trivia.ts";
export * from "./generate_source.ts";
export * from "./get_user_input.ts";
export * from "./logger.ts";
export * from "./pick_trivia.ts";
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { TRIVIA } from "types";
import { ALL_TRIVIA } from "../trivia/mod.ts";

export function getFirstTrivia(
providedTrivia: TRIVIA[] = ALL_TRIVIA,
): TRIVIA {
return providedTrivia[0];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"imports": {
"std/": "https://deno.land/std@0.89.0/",
"types": "./types/mod.ts",
"helpers": "./helpers/mod.ts"
}
}
13 changes: 13 additions & 0 deletions bundler/tests/deno-exec/deno-9350/full-2021-04-14/input/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { parse } from "std/flags/mod.ts";
import printStats from "./print_stats.ts";
import { getNumericInput, printQuestion } from "helpers";

const args = parse(Deno.args);

if (args.stats) {
printStats();
} else {
printQuestion("How many times have you played");

console.log(await getNumericInput());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ALL_TRIVIA } from "./trivia/mod.ts";

export default () => {
console.log("Number of Trivia Questions:", ALL_TRIVIA.length);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { TRIVIA } from "types";
import { generateTVSource } from "helpers";

const trivia: TRIVIA[] = [{
question: "Where did episode 1 take place",
correctAnswer: "On a boat",
wrongAnswers: ["On a plane", "On a mountain", "On a beach"],
source: generateTVSource("A TV Show Episode 1"),
}];

export default trivia;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { TRIVIA } from "types";
import aTVShow from "./a_tv_show.ts";

export const ALL_TRIVIA: TRIVIA[] = [...aTVShow];
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface SOURCE {
name: string;
mediaType: string;
}

export interface TRIVIA {
question: string;
correctAnswer: string;
wrongAnswers: [string, string, string];
source: SOURCE;
}

0 comments on commit 487eb01

Please sign in to comment.