014-007-001

Template Method Pattern: Document Processing

Easy

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

Normal case
Input:
summary
Expected 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 summary.txt
[Step 5] Closing: Releasing PDF resources
==================================
Normal case
Input:
invoice
Expected 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 invoice.txt
[Step 5] Closing: Releasing PDF resources
==================================

Your Solution

Current Mode: My Code
DocumentProcessor.java🔒
PDFProcessor.java🔒
Solution.java🔒
3/6 ファイル501B
public class DocumentProcessor {
// Define the final template method and protected step methods here
}
0 B / 5 MB

You have 10 free executions remaining