Skip to content

Tutorial abstract class #6

@ashwinkjoseph

Description

@ashwinkjoseph

Task Description
Set up an abstract class for tutorials, which should define the methods and the APIs for a tutorial in the context of TPF learning section's tutorial.
In the context of TPF, a tutorial should have the following behaviour:

  • Should define a method which would handle user input and valuable user interaction.
  • Should optionally define a method which would handle minimize/close events of an editor (this can be used in cases when a terminal and an editor both use the same parent div and visual space, to switch between the two)
  • When initialising, it should:
    • Maintain references to the pre-initiated instances of the runtime and the file system which will be used throughout a lesson.
    • Accept an HTML Div Element and initialise an instance of the required terminal giving it the HTML Div Element and also passing it the instance of the filesystem that it should use and also the function for handling user input
    • If an editor is required, accept an HTML Div Element and initialise an instance of the necessary editor giving it the HTML Div Element and a UUID, and should pass it a callback function to handle the events of closing/minimising terminal

Acceptance criteria for task

  • Check that the implementations of the class have a private method named onUserAction
  • Check that the implementation of the class have a private variable named terminal
  • Check that the implementations of the class have a private variable named runtime
  • Check that the implementations of the class have a private variable named filesystem

Additional context
Shiva Raju has an excellent 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');
		}
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions