class Teacher { /** * Creates a Instance of Teacher * * @param {String} teacher - Code for the teacher. * @param {Object} teacherList - Object of teachers. */ constructor(teacher, teacherList) { /** @returns {String} Teacher's code */ this.code = teacher; teacher = teacherList && teacherList[this.code] ? teacherList[this.code] : {}; /** @returns {String} First name(s) of the teacher. If unset the teacher's code. */ this.firstName = teacher.firstName ?? this.code; /** @returns {String} Last name of the teacher. If unset the teacher's code. */ this.lastName = teacher.lastName ?? this.code; let name = []; if(teacher.firstName) name.push(teacher.firstName); if(teacher.lastName) name.push(teacher.lastName); /** @returns {String} Full name of the teacher. If unset the teacher's code. */ this.fullName = name.join(" ") || this.code; } } module.exports = Teacher