Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 5 Instructions: Any good gaming console can load multiple games. For this assignment implement the following classes and behaviors. 1. Create a Game Class.

Assignment 5 Instructions:

Any good gaming console can load multiple games. For this assignment implement the following classes and behaviors.

1. Create a Game Class. The constructor for the Game class should take the games name as an argument.

2. Create a GameConsole Class. The constructor should create an empty array named games. Give the GameConsole a function called load. The load function should create three new Game objects, "Zelda", "Halo", and "Mario" and put them in the games array.

3. Give the GameConsole a function named log. This function should iterate over the games array and display the name of each game the console has loaded.

*Do not use Html*

Existing Code:

const prompt = require('prompt-sync')();

var adventurersName = ["Captain Thomas King","George","Tim","Sarah","Mike","Edward",]; var len = 0; var Inventory = new Array(5).fill(" "); Inventory[len++] = "Food"; Inventory[len++] = "Wine"; Inventory[len++] = "Horses"; Inventory[len++] = "Medicine";

var adventurersKilled = 3; var survivors; var numberOfAdventurers = adventurersName.length;

survivors = numberOfAdventurers - adventurersKilled;

displayIntroduction(); displayMenu(); getLeader();

var user_life = 3; var user_health = 100; var correct_answer = ["1","2","3"]; var userIsCorrect; var options = [" Option 1 Enter the village hut?","Option 2 Eat the turkey leg?","Option 3 Sit on the stool?","Option 4 Talk with the shadowy figure? "];

adventurersName[0] = prompt("Enter Leader Name: ");

while (user_life>0) { user_life = game(adventurersName[0],options);

if (user_life === 0) { var play_again = prompt("Do You Want Play Again (y/n)? ");

if (play_again =="y") { user_life= 3; user_health = 100; adventurersName[0] = prompt("Enter Leader Name:"); } else { console.log("Game Ended.Bye!"); break; } }

if (user_health === 0) { user_life= user_life-1; user_health= 100; }

else{ var play_continue = prompt("Do You Want continue the Play(y/n)? "); if (play_continue == "n") { console.log("Game Ended.Bye!"); break; } } }

function getLeader(){ let name = prompt("Enter your name: "); return name; }

function game(leader,options) {

showOptions(options); userIsCorrect = 0; const input = prompt("Enter Your choice (Number) ");

for(var i=0;i

if (userIsCorrect) { console.log("Yay, you picked the right option. After you are finished, you take a look at some of the items around you and compare them to the items you already have, would you like to pick up one of them?"); console.log("Your Inventory Items: "); for(var i=0;i

if(len == 5) { console.log("Your Inventory is full!"); var swap_option = prompt("DO you want to swap(y/n):"); if(swap_option == 'y') { console.log("Your Inventory Items: "); for(var i=0;i

function showOptions(option) { console.log(option[0]); console.log(option[1]); console.log(option[2]); console.log(option[3]); }

function displayStats(user_life,name) { console.log(" Current Statistics: Leader Name: ",name," User Health: ",user_health," Lives Remaining: ",user_life); console.log("Adventurers in your party = " + survivors); }

function displayIntroduction() {

console.log("Welcome to The God Among Us "); console.log("A group of adventurers began their search for the mystical god said to live among us. In charge of the squad was " + adventurersName[0] + " who was famous for his past exploits. Along the way, the group of comrades were attacked by the god's loyal followers. The adventurers fought with bravado and strength under the tutelage of " + adventurersName[0] + " the followers were defeated but they still suffered great losses. After a headcount of the remaining squad, " + adventurersKilled + " were found to be dead which left only " + survivors + " remaining survivors. "); console.log("Current Statistics : "); console.log("Total Adventurers = " + numberOfAdventurers); console.log("Adventures Names:");

for (var i = 0; i < numberOfAdventurers; i++) console.log("\t" + adventurersName[i] + ", "); console.log("Total Killed = " + adventurersKilled); console.log("Total Survived = " + survivors);

}

function displayMenu() {

}

function doDamage() { user_health= user_health-25; console.log("Health is Lost!") }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions