The-Programming-Foundation / learningcodesnippets

This repo consists of all the code snippets for the Learning section of the website
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

File System Abstract Class #3

Open ashwinkjoseph opened 4 years ago

ashwinkjoseph commented 4 years ago

Task Description Set up an abstract class for filesystem which should define the methods and the APIs for a File System in TPF learning section's tutorials.

and get the reference to instances of files

In the context of TPF, a file system should have the following behaviour:

Acceptance criteria for task

Additional context Shiva Raju has a very good implementation for the abstract class in Javascript. Refer to this if you are unsure about how to do it.

class PFEditorAbstractClass {
    constructor() {
        if (this.constructor === PFEditorAbstractClass) {
            throw new TypeError('Abstract class "PFEditorAbstractClass" cannot be instantiated directly.');
        }

        //abstract method for mounting an Editor into a DOM Elemement must be implemented
        if(!typeof this.mountEditorToDOMElement === 'function'){
            throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
        }

                 if (this.content === undefined) {
                         throw new TypeError('Classes implementing PFEditorAbstractClass must have the content as an attribute')
                 }

        //abstract method for storing one or more variables in local storage must be implemented
        if(!this.saveContent === 'function'){
            throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
        }]

        //abstract method for retrieving one or more variables from local storage must be implemented
        if(!typeof this. this.getContent === 'function'){
            throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
        }

        //abstract method for closing the Editor after necessary cleanup operations must be implemented
        if(!typeof this.closeEditor === 'function'){
            throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
        }

        //abstract method for minimizing the Editor after necessary saving operations must be implemented
        if(!typeof this.minimizeEditor === 'function'){
            throw new TypeError('Classes implementing PFEditorAbstractClass class must implement all its methods');
        }
    }
  }
jingshumeng commented 4 years ago

I'm working on this issue.