Template Method Pattern: Document Processing
Problem Description
Template method Pattern: Document Processing
In this problem, you will create a program that implements the Template method Pattern by defining a fixed processing flow with a final method in the abstract class DocumentProcessor, then overriding each step in the subclass PDFProcessor, and displays the result to standard output. Read a document name from standard input and use it as the filename in the save step.
Learning Objective: Fix processing flow with final method
Create a document processing system. Define the processing flow with a final method in the DocumentProcessor class, and customize each step in the PDFProcessor class. Read a document name using Scanner and pass it to processDocument(String documentName).
Input
Document name (1 line)
Output
===== PDF Document Processing =====
[Step 1] Opening: PDF Reader
[Step 2] Reading: Extracting text from PDF
[Step 3] Processing: Converting to plain text
[Step 4] Saving: Saving as {documentName}.txt
[Step 5] Closing: Releasing PDF resources
==================================
Sample Input
report
Sample Output
===== PDF Document Processing =====
[Step 1] Opening: PDF Reader
[Step 2] Reading: Extracting text from PDF
[Step 3] Processing: Converting to plain text
[Step 4] Saving: Saving as report.txt
[Step 5] Closing: Releasing PDF resources
==================================
Test Cases
※ Output examples follow programming industry standards
summary
===== PDF Document Processing ===== [Step 1] Opening: PDF Reader [Step 2] Reading: Extracting text from PDF [Step 3] Processing: Converting to plain text [Step 4] Saving: Saving as summary.txt [Step 5] Closing: Releasing PDF resources ==================================
invoice
===== PDF Document Processing ===== [Step 1] Opening: PDF Reader [Step 2] Reading: Extracting text from PDF [Step 3] Processing: Converting to plain text [Step 4] Saving: Saving as invoice.txt [Step 5] Closing: Releasing PDF resources ==================================
Your Solution
You have 10 free executions remaining
