123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import {Author, Book, DamageLogger, Librarian} from './interfaces';
- class UniversityLibrarian implements 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 };
|