[Wiki] Статическая типизация
by Artem
JavaScript
'use strict';
function Wiki(format) {
this.format = format;
}
Wiki.formats = {};
Wiki.formats.MEDIAWIKI = function(source) {
return new MWPage(source);
};
Wiki.prototype.displayPage = function(source) {
const page = this.format(source);
const title = page.getTitle();
const author = page.getAuthor();
const output = page.toHTML();
}
function Page(source) {
this.source = source;
}
function MWPage(source) {
Page.call(this, source);
}
MWPage.prototype = Object.create(Page.prototype);
MWPage.prototype.getTitle = function() {};
MWPage.prototype.getAuthor = function() {};
MWPage.prototype.toHTML = function() {
console.log(`<a href="${this.source}">${this.source}</a>`);
};
const app = new Wiki(Wiki.formats.MEDIAWIKI);
app.displayPage('https://www.google.com');