UNPKG

oop-console-app

Version:

basic concepts of Object Oriented Programming

48 lines (45 loc) 1.46 kB
#! /usr/bin/env node import inquirer from "inquirer"; import Person from "./person.js"; import Student from "./student.js"; class Program { static Main() { const person = new Person(); inquirer.prompt([ { type: "list", name: "personality", message: "Select your personality: ", choices: [ { name: "like to talk to other", value: 1 }, { name: "you like to keep to yourself", value: 2 } ] } ]).then((answers) => { const student = new Student(); student.askQuestion(answers.personality); // console.log(`You are an ${person.getPersonality()}.`); inquirer.prompt([ { type: "input", name: "name", message: "What is your name?", validate: function (input: any) { return input.length > 0 || "Please enter your name."; } } ]).then((answers) => { student.name = answers.name; console.log(`Hello ${student.name}! You are ${student.getPersonality()}.`); }); } ); } } Program.Main();