Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Create two JavaScript classes:PoloShirt: represents a single polo shirt in the closet Properties A string that contains the name of the predominant color of this shirt Closet: represents the closet in which polo shirts are stored1Properties An array of PoloShirt objects Methods addShirt(PoloShirt): appends the given PoloShirt to the PoloShirt array Returns the number of items in the PoloShirt array after adding the parameter removeShirt(): removes the first PoloShirt in the PoloShirt array Returns the number of items remaining in the PoloShirt array printCloset(): print all elements of the PoloShirt array one line at a time in the format ${count} ${color} shirtsex

Create two JavaScript classes:PoloShirt: represents a single polo shirt in the closet Properties A string that contains the name of the predominant color of this shirt Closet: represents the closet in which polo shirts are stored1Properties An array of PoloShirt objects Methods addShirt(PoloShirt): appends the given PoloShirt to the PoloShirt array Returns the number of items in the PoloShirt array after adding the parameter removeShirt(): removes the first PoloShirt in the PoloShirt array Returns the number of items remaining in the PoloShirt array printCloset(): print all elements of the PoloShirt array one line at a time in the format ${count} ${color} shirtsex

Computer Science

Create two JavaScript classes:PoloShirt: represents a single polo shirt in the closet

  • Properties
  • A string that contains the name of the predominant color of this shirt
  • Closet: represents the closet in which polo shirts are stored1Properties
  • An array of PoloShirt objects
  • Methods
  • addShirt(PoloShirt): appends the given PoloShirt to the PoloShirt array
  • Returns the number of items in the PoloShirt array after adding the parameter
  • removeShirt(): removes the first PoloShirt in the PoloShirt array
  • Returns the number of items remaining in the PoloShirt array
  • printCloset(): print all elements of the PoloShirt array one line at a time in the format ${count} ${color} shirtsex. 3 burgundy shirts

Examples

const shirts = [
                 new PoloShirt('red'),
                 new PoloShirt('green'),
                 new PoloShirt('blue'),
                 new PoloShirt('red')
               ];

const closet = new Closet();

closet.printCloset(); // prints nothing

for (let shirt of shirts) {
  console.log(closet.addShirt(shirt)); // returns 1, 2, 3, 4
}

closet.printCloset(); // prints 2 red shirts
                      //        1 green shirts
                      //        1 blue shirts
                      
console.log(closet.removeShirt()); // returns 3

closet.printCloset(); // prints 1 red shirts
                      //        1 green shirts
                      //        1 blue shirts
                      
console.log(closet.removeShirt()); // returns 2

closet.printCloset(); // prints 1 red shirts
                      //        1 blue shirts

console.log(closet.removeShirt()); // returns 1

closet.printCloset(); // prints 1 red shirts

console.log(closet.removeShirt()); // returns 0

closet.printCloset(); // prints nothing

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE