Commit bb1cae7b authored by Chingiz's avatar Chingiz 💻

Added some impruvments

parent be6aca93
...@@ -120,23 +120,21 @@ export class Control { ...@@ -120,23 +120,21 @@ export class Control {
} }
start() { start() {
let out: boolean = true; let out: boolean = true;
console.log("Hello, your robot name is D2R. Please, take controle of him. \n");
while (out) { while (out) {
const answerFromUser: string | null = readline.question( const answerFromUser: string | null = readline.question(
"Choose one of the commands: \n1) See my tool\n2) Use my tool\n3) Drop my tool\n4) Choose one of the tools\n5) Exit:\n " `Choose one of the commands: \n1) ${this.robot.tool ? "Use the "+ this.robot.tool.toolName : "No tools to use!"}\n2) ${this.robot.tool ? "Drop the " + this.robot.tool.toolName : "No tools to drop!"}\n3) ${this.robot.tool ? "Your tool is " + this.robot.tool.toolName : "Choose one of the tools"}\n4) Exit:\n `
); );
switch (answerFromUser) { switch (answerFromUser) {
case "1": case "1":
console.log("============================================");
console.log("I am using ", this.robot.tool?.toolName || "Nothing");
console.log("============================================");
break;
case "2":
this.robot.action(); this.robot.action();
break; break;
case "3": case "2":
this.robot.drop_tool(); this.robot.drop_tool();
break; break;
case "4": case "3":
const answer = readline.question( const answer = readline.question(
"Please, choose one of the tool: \n1) Saw\n2) Hammer\n3) screwdriver\n4) Axe\n5) Drill\n" "Please, choose one of the tool: \n1) Saw\n2) Hammer\n3) screwdriver\n4) Axe\n5) Drill\n"
); );
...@@ -163,7 +161,7 @@ export class Control { ...@@ -163,7 +161,7 @@ export class Control {
break; break;
} }
break; break;
case "5": case "4":
out = false; out = false;
default: default:
console.log("============================================"); console.log("============================================");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment