Changes

Jump to: navigation, search

Console Class - OOP344 20121

5,910 bytes added, 15:00, 23 January 2017
Help Needed
{{OOP344 Index | 2011320121}}Under Construction!!=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!)* [https://cs.senecac.on.ca/~chris.szalwinski/resources/borland.html 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=
*Wed, Feb 1st, 23:59
 
 
==Help Needed==
*<font color=green size=3>'''How to submit?''' </font>
----
 
*[http://777sblog.blogspot.com/2012/01/problem-with-cio-tester-45.html <s>I have a problem with cio tester (4.5)</s>]
 
----
 
*[http://yudongxu.blogspot.com/2012/01/problem-with-test-417.html I have a problem with tester 4.17]
**I have answered your question on my [http://777sblog.blogspot.com/2012/02/dons-answer-to-his-question-about-test.html blog] since yours is all in Chinese (I think..) I didn't know what button to press...
 
----
 
*Guys, where is the link to the right tester ? When I run that one from SVN - it shows me - cio_test.cpp(700): error C2065: 'CIO_TABSIZE' : undeclared identifier . Does somebody know what is the problem ?
**Did you add the #define CIO_TABSIZE 4 to the console.h header file?
** Yes you have to add this, you can also add it to bconsol.h and fardad hasn't yet updated the tester for submission... --Sezar 6:49pm Feb 01 2012
 
----
 
*Is anyone having the issue where after Test 10, the general test, once it's over and the console asks "Did everything work correctly?", no matter what key you hit, it simply crashes? I have never seen any message saying I've passed all tests or even to keep trying. I pass all tests but the final question, doesn't seem to take my answer. It just displays a 30 near the top area. To recreate what I'm saying, try pressing any other key other than "Y" when you're asked a question. That action is exactly what I'm getting. -- adsantokhi 6:58PM Feb 01.
** please update the cio_test (v0.92) and the final one still not there yet... we have to wait for fardad to update the test for submission!! -- Sezar 7:28 01 Feb 2012
**I'm using v0.92. Still getting this problem. --adsantokhi 7:46PM Feb 01.
**well 30 is the last screen! so you are done all you have to do is just wait for the submission test thats what it says at the end of the test (screen 30).. -- sezar 7:57PM
 
----
 
*is anyone else having problems compiling on matrix? something about "cio_test.cpp:792: warning: deprecated conversion from string constant to 'char" and a billion similar errors on different lines? --apetrus 10:30PM Feb 01
** Now it's telling me something about "The row and column of the terminal must be maximum of 30 by 100". Has anyone experienced this problem? Works fine on visual studio -- apetrus 11:35PM Feb 01
***You have to change the buffer size to be a width of 100 and height of 30. Are you sure this is matrix and not on your local pc binary created by borland? Right click on the top of the window (window header) and select properties. From there go to the layout tab and change the "Screen Buffer Size" accordingly. --btulchinsky 23:41 Feb 01
 
----
 
*Can anyone help me out? I can't figure out 4.24: It stops when I press 'a'. I'm not sure what's the problem. It's probably has to do with IsTextEditor, but I'm still not sure what exactly the problem is. --dkavalchyk2 09:30AM-Feb-02
 
----
*Final successful submission should be this..... [http://codingstar.blogspot.com/2012/02/final-screenshot-of-assignment-1.html Screenshot]--[[User:Tvirutthasalam|Tvirutthasalam]] 10:20, 6 February 2012 (EST)
 
----
*is anyone having problems with the output on matrix. When i do a.out i get stuck on the test 4.4 where i hit the insert button and the test ends. But in Visual studio it works fine. Any help? --smahmed9 4:03PM
**my mistake. forgot cannot use ssh. Used putty and done. --smahmed9 05:18PM
 
=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.
Your submission consists of class called Console that is to be inherited from BConsole in a namespace called '''cio'''. Your application module is fully portable, 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, implimented 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:
This method is to be written in two steps.
====Step one====
''Ignore the last two arguments of the the edit method '''(IsTextEditor, and ReadOnly) ''' and write the method as follows:''
This methods edits the C-style, null-terminated string pointed to 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 to a bool variable that holds the current insert mode of the string. The parameter insertMode receives the address of a variable that stores the current editing mode - insert or overwrite. 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.
You may assume that it is the calling program's responsibility to ensure that the string array is large enough to handle maxStrLength characters and that the starting screen position provides enough room (on the screen) for the field, etc.
 
This shows the edit method function in a diagram below:
[[File:Editmethod.jpg|400px|thumb|center|Edit Method Function Diagram]]
 
A slightly easier to read version of the above image:
[[File:classNoteJan23.jpg|400px|thumb|center|Edit Method Function Diagram]]
 
====Step two====
''First run your program with cio_test.cpp and make sure it passes all the tests up to and including "4.16". If all tests are passed continue with step two:
 
=====IsTextEditor=====
If '''IsTextEditor''' is true and the value of '''*strOffset''' is changed at any time, then terminate the edit function immediately and return '''0''';
======TAB key======
If '''IsTextEditor''' is true and TAB key is hit, then instead of terminating the function, ''CIO_TABSIZE'' spaces are inserted into ''str''.
 
=====ReadOnly=====
If '''ReadOnly''' is true, then edit function works exactly like before, except that any modification to the data (the content of the '''str''' string) will be ignored.
 
===Overloading "<<" 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;
Console& operator<<(Console& cn, const char* str);
print the string '''str''' on the screen where the cursor is using '''cn'''
 
===Tester Program===
Local PC: Borland 5.5
bcc32 bconsole.cpp console.cpp yourtestprogramcio_test.cpp 
Local PC: Microsoft .net
matrix: GNU (use -lncurses to link ncurses library)
g++ bconsole.cpp console.cpp yourtestprogramcio_test.cpp -lncurses 
For submission purposes, your solution must compile, link, and run without errors in each environment.
ZIP (ZIP only) keys.h, console.h, console.cpp, yourtestprogram.cpp into one file and email it to:
[mailto:fardad.soleimanloo@senecac.on.ca?subject=OOP344-console2.0 fardad.soleimanloo@senecac.on.ca]
 When your program passed all the tests, on matrix, create a directory and copy all the source files (To console.cpp, console.h, bconsole.cpp, bconsole.h) into it. Then copy cio_test.o from "~fardad.soleimanloo" and then compile your code with your professors version of cio_test (i.e cio_test.o) and run it. If all the tests are passed successfully, an email will be completedsent to your professor automatically with your source code (console.h and console.cpp)to copy the cio_test.o do the following.<br />From the directory containing all source files: $cp ~fardad.soleimanloo/cio_test.o .to compile the code: $g++ bconsole.cpp console.cpp cio_test.o -lncursesThis should not generate any warnings.<br />To run the test (with automatic submission) $a.out
9
edits

Navigation menu