Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

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 Sep 15, 2020

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

Expert Solution

For detailed step-by-step solution, place custom order now.
Need this Answer?

This solution is not in the archive yet. Hire an expert to solve it for you.

Get a Quote
Secure Payment