Project R0.1 20123- OOP344
OOP344 | Weekly Schedule | Student List | Teams | Project | Student Resources
Contents
Release
- 0.1
Notes
- Using Linux: please use putty only and set the keyboard to
- Backspace = Ctrl-?
- Home and End = Standard
- Function keys and keypad = Linux
- And then:
- Connection > Data > Terminal-type string = linux (This step must be done when first connecting through putty!)
- Guide for Using Borland 5.5
- Note that to change the cmd.exe window size, right click on the top bar -> Properties -> Layout Tab
Due Dates
- Fri Oct 12th, 23:59
Help
Help Needed
Blog Posts
Learning Outcome
Upon successful completion of this first assignment, you will have demonstrated the abilities to design and code
- functions that use the basic console input and output library
- a line editor
- use of extern
- operator overload
- use of namespaces
Console Line Editing Facility
As your first assignment, you are to upgrade the basic console input output class (BConsole) to include line-display and line-editing facilities and use of "<<" and ">>" operators for character I/O and string output.
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++, Viusual 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 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:
In addition to all public methods of BConsole, Console must have the following two public methods and overload "<<" and ">>" operators.
external links
- Create a global variable (unsigned int) for CIO_TABSIZE in cio namespace and create an external linkage to it in console.h
- instantiate Console, in an object called "console" in cio namespace and create an external linkage to in console.h
display() method
void display(const char *str, int row, int col, int fieldLen=0);
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. 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 portion of the entire string that fits on the screen, followed by enough trailing spaces to fill out the field completely. If fieldLen is 0, your function displays the portion of the entire string with no trailing spaces. Your function positions the cursor after the last character displayed. Your function does not flush the output buffer. The results are undefined if the starting position of the string is not within the dimensions of the screen.
edit() method
under construction!
Overload "<<" and ">>" operators
operator>>
Console& operator>>(Console& cn, int& ch);
Get a key from keyboard using cn and store it in ch;
operator<<
Console& operator<<(Console& cn, char ch);
Print the character ch on the screen, where the cursor is located, using cn and return the cn reference;
Console& operator<<(Console& cn, const char* str);
print the string str on the screen where the cursor is using cn and return the cn reference
Submission
Compile and test your upgrade with your test main in the following three command-line environments:
Local PC: Borland 5.5
bcc32 bconsole.cpp console.cpp cio_test.cpp
Local PC: Microsoft .net
Local Mac: (use -lcurses to link curses library)
c++ bconsole.cpp console.cpp cio_test.cpp -lcurses
matrix: GNU (use -lncurses to link ncurses library)
g++ bconsole.cpp console.cpp cio_test.cpp -lncurses
For submission purposes, your solution must compile, link, and run without errors in each environment.
Method of submission will be announced later.