Changes

Jump to: navigation, search

Project R0.1 20133 - OOP344

454 bytes added, 08:19, 26 September 2013
Specifications
Your submission consists of a class called Console that is to be inherited from BConsole in a namespace called '''cio'''. Your application module is fully portable across Borland C++5.5 on windows, Linux GNU C++, Visual C++ on Windows and Mac C++ platforms which accepts console input, and provides console output through the set of facilities available in your Console module.
The name of the library object (i.e. the global instance of Console) to be created is console. The header file for the original version of this module is console.h and the implementation file for the original version is console.cpp. All of the identifiers for the library module and all upgrades to the module are defined in the cio namespace (short for console input output).
Your upgrade in this assignment consists of creating a class called Console, inherited from BConsole, implemented in two files; console.h and console.cpp:
void display(const char* str, int row, int col, int fieldLen=0, int curpos = -1);
This method outputs the C-style, null-terminated string pointed to by str starting at row ''"row" '' and column ''"col" '' of the screen in a field of fieldLen characters(Row value 0 refers to the top row, and column value 0 refers to the left-most column) and positions the cursor at "curpos" location relative to "col", only if it is greater or equal to zero.<!--If the value of curpos is placing the cursor after the last character of str, then the value is ignored and the cursor is placed right after the last character of str. (Joseph: is this needed?)-->
If the string is longer than fieldLen, your function displays the first fieldLen characters. If the string is shorter than fieldLen, your function displays the entire string, followed by enough trailing spaces to fill out the field completely.
''Ignore the two arguments '''(InTextEditor and ReadOnly)''' for now write the method as follows:''
This method edits the C-style, null-terminated string pointed by str. The parameter row holds the row (0 is the top row) of the string on the screen. The parameter col holds the starting column (0 is the left-most column) on the screen. The parameter fieldLength holds the length of the editable field. The string may be larger than the field itself, in which case part of the string is hidden from view. The parameter maxStrLength holds the maximum length of the string, excluding the null byte. The parameter insertMode points is a reference to a bool variable that holds stores the current editing mode (insert mode of the stringor over-strike). The By default, this parameter insertMode receives hold the address reference of a variable that stores static bool attribute of the Console class (i.e. _insertMode) which globalizes the current editing insert/over-strike mode - insert or overwritebetween all instances of '''Console'''. The parameter strOffset points to an int variable that holds the initial offset of the string within the field; that is, the index of the character in the string that initially occupies the first character position in the field. The parameter curPosition points to an int variable that holds the initial cursor position within the field; that is, the index of the character in the field at which the cursor is initially placed.
* '''''Initial Corrections'''''
*:Do the following initial corrections before you engage in editing the string at the very beginning of the method.
*:If the initial offset is beyond the end of the string, your function resets the offset to the length of the string; that is, to the index of the character immediately beyond the end of the string. If no offset variable is pointed to; that is, if the address of the variable is NULL, your function sets the offset to the index of the first character in the string; that is, to 0. (to do this have a local variable for the offset that holds zero to be pointed instead of an external variable)
*:If the initial cursor position is beyond the end of the field, your function resets the position to the last character in the field. If the position is beyond the end of the string, your function resets the position to that immediately beyond the end of the string. If no cursor position variable is pointed to; that is, if the address of the variable is NULL, your function sets the cursor position to the first position in the field; that is, to position 0.(like the offset, to do this have a local variable for the cursor position that holds zero to be pointed instead of an external variable)

Navigation menu