import * as I from './interfaces';

class UniversityLibrarian implements I.Librarian {
  department: string;
  email: string;
  name: string;

  assistCustomer(custName: string): void {
    console.log(`${this.name} is assisting ${custName}.`);
  }
}

abstract class ReferenceItem {
  static department = 'Research';
  private _publisher: string;

  constructor(public title: string, protected year?: number) {
  }

  printItem(): void {
    console.log(`${this.title} was published in ${this.year}`);
    console.log(`Department: ${ReferenceItem.department}.`);
  }

  get publisher(): string {
    return this._publisher.toUpperCase();
  }

  set publisher(p: string) {
    this._publisher = p;
  }

  abstract printCitation(): void;
}

class Encyclopedia extends ReferenceItem {
  constructor(newTitle: string, newYear: number, public edition: number) {
    super(newTitle, newYear);
  }

  printItem(): void {
    super.printItem();
    console.log(`Edition: ${this.edition} (${this.year}).`);
  }

  printCitation(): void {
    console.log(`${this.title} - ${this.year}.`);
  }
}

class Journal extends ReferenceItem {
  public contributors: string[];

  constructor(title: string, year: number) {
    super(title, year);
  }

  printCitation(): void {
    console.log(`${this.title} - ${JSON.stringify(this.contributors)}.`);
  }
}

export { Encyclopedia, Journal, ReferenceItem, UniversityLibrarian };