|
Time |
Memory |
| Case 1 |
1 sec |
32 MB |
| Case 2 |
1 sec |
32 MB |
| Case 3 |
1 sec |
32 MB |
| Case 4 |
1 sec |
32 MB |
Description
In this problem, a user can input some “words”, set their formats, and change their contents.
The program architecture is explained as follows.
A. Definition of class Formatter
- Consider a Formatter as a capability to format a string.
- Different Formatters will use different ways to format a string.
- Derived classes
- Uppercase
- After formatted, the resultant string will be uppercase.
- Lowercase
- After formatted, the resultant string will be lowercase.
- Marked
- After formatted, the resultant string will be [given string].
B. Definition of class Word
- A Word contains a string and a Formatter.
C. Definition of class Handler
- Consider a Handler as a capability to operate two Words.
- Different Handlers will use different ways to operate two Words.
- Derived classes
- Swap Handler
- After operation, two Words will exchange their strings and Formatters.
- Attach Handler
- After operation, the second Word’s string will be appended to the first Word’s string.
D. Definition of class Word Manipulator
- A Word Manipulator maintains a doubly linked list of several Words.
- A Word Manipulator has a Swap Handler and an Attach Handler. We can switch the mode of a Word Manipulator to change the current Handler.
Note:
1. This problem involves three files.
- function.h: Class definitions.
- function.cpp: Member-function definitions.
- main.cpp: A driver program to test your class implementation.
You will be provided with main.cpp and function.h, and asked to implement function.cpp.
2. You need to implement
- string format(const string &str)
- string format(const string &str)
- string format(const string &str)
- const Word &operator=( const Word &w)
- void handle(Word &w1,Word &w2)
- void handle(Word &w1,Word &w2)
- void switchMode()
- void readWords()
3. For OJ submission:
Step 1. Submit only your function.cpp into the submission block.
Step 2. Check the results and debug your program if necessary.
Input
First part:
- Each line has a command and a string. You have to read the string to a Word and set a corresponding Formatter to it according to the command.
- A command e means the end of the first part.
- Commands
Use Uppercase
Use Lowercase
Use Marked
Second part:
There are two kinds of commands
- s
- Switch the mode of Word Manipulator.
- o n m
- Let Word Manipulator operate (n, m) where n and m are the indices of two Words.
Output
Show the result of Word Manipulator.
Partial Judge Code
11439.cpp
Partial Judge Header
11439.h
Tags