Build Specifications First, in a Player.ts file, create and export an interface called Player that has the following pro

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Build Specifications First, in a Player.ts file, create and export an interface called Player that has the following pro

Post by answerhappygod »

Build Specifications
First, in a Player.ts file, create and export an interface called Player that has the following
properties:
name (string)
⚫ jersey (number)
⚫active (boolean)
Next, in a Team.ts file, create and export a class called Team with the following members:
Properties:
⚫ players (array of Player)- starts an an empty array
teamName (a string)
Methods:
constructor: use a parameter to set the teamName
.addPlayer method, which takes a Player object as a parameter and adds it to the list ⚫ removePlayer, which takes an index of a player and removes it from the list.
.setActive, which takes an index of a player, and a boolean for active or inactive, and stores the boolean in that player's active member.
⚫ getPlayerCount: Takes no parameters; returns the number of players.
⚫logActivePlayers: Log to the console, one per line, a list of players whose active
status is set to true
⚫ getActivePlayers: Returns a list of players whose active status is set to true
Manually test your code by exercising each method in index.ts. Create one or more Team instances, add players, and call the various methods.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply