...

/

Challenge: Composite Pattern

Challenge: Composite Pattern

In this challenge, you have to implement the composite pattern to solve the given problem.

Problem statement

In this challenge, you have to implement a directory system using the composite pattern.

You have been given the following skeleton code:

Press + to interact
class Directory{
constructor(name,lastModified,size){
this.name = name
this.lastModified = lastModified
this.size = size
}
getLastmodified(){}
getSize(){}
getName(){}
}
class File extends Directory{
}
class Folder extends Directory{
}

It’s up to you to figure out which class will be the component, leaf subclass, and composite subclass.

A Directory has the following properties:

  • name: the name of the file/folder ...