Implement a simplified filesystem using Object Oriented Programming consisting of only Files and Directories. Directories can contain Files or other Directories. Both Files and Directories should have attributes 'name', 'filesize', 'writeable'.
Given a 'tree' that looks like Directory
/*
Implement a simplified filesystem using Object Oriented Programming
consisting of only Files and Directories. Directories can contain
Files or other Directories. Both Files and Directories should have
attributes 'name', 'filesize', 'writeable'.
Given a 'tree' that looks like
Directory
- File
- Directory
- Directory
- File
Change the 'writeable' attribute for each object from true to false
*/
class Directory extends File {
constructor(name, filesize, writeable, children = []) {
super(name, filesize, writeable);
this.children = children;
}
setWriteable(writeable) {
super(writeable);
for (const child of this.children) {
child.setWritable(writeable);
}
}
}
class File {
constructor(name, filesize, writeable) {
this.name = name;
this.filesize = filesize;
this.writeable = writeable;
}
setWriteable(writeable) {
this.writeable = writeable;
}
}