Visitor Pattern Lab 1

Lab Assignment: Adding a New Document Type

You have been given a document processing system that uses the Visitor pattern to perform operations on different document types. Your task is to add a new document type called ImageDocument to the system and ensure it is compatible with the existing visitor infrastructure.

Requirements:

  1. Implement a new class called ImageDocument that represents an image document. The ImageDocument class should implement the Document interface and provide its own implementation of the accept and getTitle methods.

  2. Modify the Main class to include an instance of ImageDocument and update the existing loops to include the new document type when applying the visitors.

  3. Test your implementation by creating instances of different document types, including the ImageDocument, and applying the print visitor and export visitor.

Note:

  • You can assume that the existing classes (DocumentVisitor, PrintVisitor, ExportVisitor, Document, TextDocument, SpreadsheetDocument, PresentationDocument, and Main) are already implemented correctly.

  • You can use the existing code provided in the previous example as a starting point for your implementation.