Challenge: Solution Review
Explore how to implement the visitor pattern to manage a music library and create a rock playlist. Understand the roles of Song, MusicLibrary, and RockMusicVisitor classes to improve object communication and behavior in JavaScript design patterns.
We'll cover the following...
We'll cover the following...
Solution #
Explanation
This challenge involved a music library containing different genres of music such as Rock, Pop, and Country. Your task was to implement the visitor pattern to perform the additional operation of creating a separate playlist for the Rock music in the library. We will look into how that is done later on.
Let’s start by discussing the Song class below:
class Song{
constructor(name,genre){
this.name = name
this.genre = genre
}
getName(){
return this.name
}
getGenre(){
return this.genre
}
}
A Song has the following properties:
-
A ...