Question: class Player { constructor ( name , position ) { this.name = name; this.position = position; } describe ( ) { return ' $ {
class Player
constructorname position
this.name name;
this.position position;
describe
return $thisname plays $thisposition;
class Team
constructorname
this.name name;
this.players ;
addPlayerplayer
if player instanceof Player
this.players.pushplayer;
else
throw new ErrorYou can only add an instance of Player. Argument is not a player: $player;
describe
return $thisname has $thisplayers.length players.;
class Menu
constructor
this.teams ;
this.selectedTeam null;
start
let selection this.showMainMenuOptions;
while selection
switch selection
case :
this.createTeam;
break;
case :
this.viewTeam;
break;
case :
this.deleteTeam;
break;
case :
this.displayTeams;
break;
default:
selection ;
selection this.showMainMenuOptions;
alertGoodbye;
showMainMenuOptions
return prompt
exit
create new team
view team
delete team
display all teams
;
showTeamMenuOptionsteamInfo
return prompt
back
create player
delete player
$teamInfo
;
displayTeams
let teamString ;
for let i ; i this.teams.length; i
teamString i this.teamsiname
;
alertteamString;
createTeam
let name promptEnter name for new team:;
this.teams.pushnew Teamname;
viewTeam
let index promptEnter the index of the team you wish to view:;
if index && index this.teams.length
this.selectedTeam this.teamsindex;
let description 'Team Name: this.selectedTeam.name
;
for let i ; i this.selectedTeam.players.length; i
description i this.selectedTeam.playersiname
this.selectedTeam.playersiposition
;
let selection this.showTeamMenuOptionsdescription;
switch selection
case :
this.createPlayer;
break;
case :
this.deletePlayer;
deleteTeam
let index prompt Enter the index of the team you wish to delete:;
if index && index this.teams.length
this.teams.spliceindex;
createPlayer
let name promptEnter name for new player:;
let position promptEnter position for new player:;
this.selectedTeam.players.pushnew Playername position;
deletePlayer
let index promptEnter the index of the player you wish to delete:;
if index && index this.selectedTeam.players.length
this.selectedTeam.players.spliceindex;
let menu new Menu;
menu.start;
help debugg
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
