- Secure Payment Guarantee
Full Question
TCP1101 Programming Fundamentals
The users of the display board program have sent you further requests to improve the program. There are two major improvements that need to be incorporated into your program from Milestone 1.
- External input file commands
To ease the use of the program (…entering input one by one is really tiring! ), modify your program to allow reading of commands from an external input file. Users should now be able to write a series of text commands, which are then input into the program to display a specific design of the scrolling banner. For ease of use, the program should ask for the input file name to process, proceed to perform the display, and return back for another round of user input when it ends. A sentinel text can be used to exit program.
The following table summarizes the commands and the order of commands, which are to be used in the text file. Note: For more information of what some of these features do, please refer to Section II (“New features”).
Sample text file (sample.dat) |
Description for each line |
# |
Drawing character (optional, defaults to ‘#’) |
5 |
Speed of refresh cycle |
Selamat Hari Merdeka |
Phrase (max 25 chars), input can be of any case |
6 18 |
Anchor point |
20 40 |
Board size (optional, defaults to 20, 40) |
lr wr rot90 |
Direction: lr, rl, ud, du, st |
|
Wrap-around: wr (optional) |
|
Rotation: rot90, rot-90,mr (optional) |
- New features
The users have requested for further new features that will enhance the board display. Please note that you may have to make substantial changes to your original program in Milestone 1 (this varies from case to case). Among the requested features are the following:
1. Different characters for drawing
Previously, you may have fixed the character used for drawing. Now, users should be allowed to specify their choice of characters for the printing. The first character in the text file indicates this. Default symbol if not specified, is a ‘#’ character.
2. Variable board size
Board sizes can now be specified by the user. The two integers (in correct order) indicate the number of rows, and the number of columns, respectively. Of course, they must still be two positive integers. There should be no limit to the dimensions of the board. Unless specified, the board size will be (20, 40) as defined in Milestone 1.
3. Scrolling wrap-around effect
There are four ways of scrolling the string: left to right (lr), right to left (rl), up to down (ud), down to up (du). You are to implement the wrap-around effect while performing the scrolling. When the string scrolls beyond the edges of the board, the part of the string pushed out will enter from the opposite edges, thus the “wrap-around” effect. This feature was postponed from Milestone 1. The user can also choose to have no scrolling effect, making the string stationary (st).
4. Rotated display
Allow the user to apply rotation to the string. There are three possible modes: Rotation by 90 degrees (clockwise) rot90, Rotation by -90 degrees (anti- clockwise) rot-90, and Mirror (vertical reflection, or flipping the object across the x-axis) mr. The rotation point is defined as the bottom-left corner of the string. At each time, only one mode is applied.
Other implementation points and caveats to note:
- Show that you are able to use functions appropriately in your code.
- Speed of refresh cycle must be a number from 1-10 (as specified in Milestone 1)
- Characters in the phrase is not case sensitive. However, your board should only display uppercase. The phrase should not be more than 25 characters in length (space included).
- For cases where a rotation command is issued:
- The anchor point remains the same top-left-most position of the string (see Fig. 2 below).
- If scrolling is on, the scrolling direction is taken with respect to the board, not the rotated string.
- The last two commands (wrap-around and rotation) can be in any order after the scrolling command, since they are optional.
- Consider carefully, all that necessary input validation that needs to be included into your program to ensure the user is properly informed of any incorrect input(s), or format/value
- Bonus features (Optional, but bonus marks can be awarded)
· “Inception” Effect
Each character in the string is drawn using its own character.
· Flash Show
A single (25-char) phrase is not enough! What if we have an entire message to show? Allow the user to add multiple sets of commands, consecutively to show a long message.
Note: Each scrolling animation (for each phrase) should end before showing the next. A delay can be specified between each phrase.