Changes

Jump to: navigation, search

OOP344 Assignment Two

1,045 bytes added, 13:15, 17 April 2013
m
Undo revision 69911 by MCanaday49 (Talk) - SPAM
[[OOP344]] - [[OOP344 Student List]] - [[OOP344 Teams]] - [[OOP344 Assignment One]] - [[OOP344 Assignment Two]] - [[OOP344 IRC Schedules 20093 |OOP344 IRC Schedules]]<br />
- [[OOP344 Student Resources]]<br />
Under construction...
=File Names=
Save your work in separate files for each class. Name , and name the files to the same name as the classes. Each ; each class should have a header file and a code file.
For example for the class IOField[[#IO_Field | IO_Field]], create iofield''IO_Field.h '' and iofield''IO_Field.cpp''. The header file should hold the class declaration , and any other possible declaration related to the class. The "cpp" file should hold the definition (implementation) of the class , and its methods and possible functions.
Create a Make file to build your project with respect to dependencies of classes.
 
=SVN Quick Notes=
# Checkout the code $svn co svn://zenit.senecac.on.ca/ops344_093aXXops344_093a'''XX'''/trunk/PRJ --username yourUserName <sup>Remember, '''XX''' is your SVN number after your section ('a' etc.)</sup>
# Add selected ciol.h ciol.cpp and if present the class files (all compiled) $svn add filename
# Commit the new files $svn commit
create a file called: '''io_def.h'''. This file will contain any necessary definitions or inclusions for the project.
for now add the following define statements in '''io_def.h'''
<big><pre>
==IO_Form==
'''[[#IO_Frame| IO_Frame]]''' is inherited into a container class called '''IO_Form'''. '''IO_Form''' organizes the '''[[#IO_Field | IO_Field]]''' classes and give the user a panel to use them sequentially.
'''IO_Form''' should be able to hold unlimited number of '''[[#IO_Field | IO_Fields]]'''. (Use either a dynamic array, or linked list structure of '''[[#IO_Field | IO_Fields]]''' to implement this)
<hr width="50%" />
===Constructor===
int add(IO_Field* f, bool dynamic, bool submitter);
</pre></big>
'''IO_Form''' uses this private '''add''' method to provide means of adding fields through several public add methods. this method adds an '''[[#IO_Field | IO_Field]]''' to the end of the '''[[#IO_Field | IO_Fields ]]''' in the IO_Form;
*'''f''' : is Is the address of the '''[[#IO_Field | IO_Field]]''' begin added to the '''IO_Form'''*'''dynamic''' : if If set to true, it sets this '''[[#IO_Field | IO_Field]]''' to be deallocated by '''IO_Form''''s destructor at the end;*'''submitter''': if If set to true, it tags this '''[[#IO_Field | IO_Field]]''' to terminate the '''IO_Form''''s edit() if ENTER_KEY is hit. see the edit() method for more info.
'''add()''' also calls '''set(IO_Form* owner)''' of '''[[#IO_Field | IO_Field]]''' and passes its pointer ''(this)'' to it. By doing this, each '''[[#IO_Field | IO_Field]]''' will know who is its owner.
'''add()''' returns the number of fields currently in IO_FORM.
<hr width="50%" />
int add(IO_Field* f, bool submitter = false);
</pre></big>
Uses the private add() method to add a dynamic IO_field'''[[#IO_Field | IO_Field]]'''.
<hr width="50%" />
<big><pre>
int add(IO_Field& f, bool submitter = false);
</pre></big>
Uses the private add() method to add a non-dynamic IO_field'''[[#IO_Field | IO_Field]]'''.
<hr width="50%" />
<big><pre>
int addHelp(IO_Label* L);
</pre></big>
Uses the private add() method to add a dynamic IO_field '''[[#IO_Field | IO_Field]]''' and also saves its address for the general help message label of the Form.
<hr width="50%" />
<big><pre>
int addHelp(IO_Label& L);
</pre></big>
Uses the private add() method to add a non-dynamic IO_field '''[[#IO_Field | IO_Field]]''' and also saves its address for the general help message label of the Form.
<hr width="50%" />
<big><pre>
int addError(IO_Label* L);
</pre></big>
Uses the private add() method to add a dynamic IO_field '''[[#IO_Field | IO_Field]]''' and also saves its address for the general error message label of the Form.
<hr width="50%" />
<big><pre>
int addError(IO_Label& L);
</pre></big>
Uses the private add() method to add a non-dynamic IO_field '''[[#IO_Field | IO_Field]]''' and also saves its address for the general error message label of the Form.
<hr width="50%" />
<big><pre>
</pre></big>
Uses the private add() method to add a non-submitter, dynamic IO_field'''[[#IO_Field | IO_Field]]'''.
<hr width="50%" />
<big><pre>
IO_Form& operator<<(IO_Field& f);
</pre></big>
Uses the private add() method to add a non-submitter, non-dynamic IO_field'''[[#IO_Field | IO_Field]]'''.
<hr width="50%" />
void* data(unsigned int fieldnumber=0);
</pre></big>
Returns address of the data of "fieldnumber"th, '''[[#IO_Field | IO_Field]]''' in the IO_Form. If "fieldnumber" is zero, then it returns the data of the current '''[[#IO_Field | IO_Field]]'''.
====The index operator====
IO_Field& operator[](unsigned int index);
</pre></big>
Returns the reference of the '''[[#IO_Field| IO_Field]]''', number "fieldnumber-1". First Field has the index 0;
<hr width="50%" />
</pre></big>
If neither of the '''[[#IO_Field | IO_Fields]]''' is editable, it displays all the '''[[#IO_Field | IO_Fields]]''', then waits for a key entry and then ends the function by returning the key entered.
If the fieldnumber pointer is NULL, it should use a local variable’s address with the value of “0” zero instead.
Call the edit of each field and depending on the value returned, do the following:
* For '''TAB_KEY''' and '''DOWN_KEY''', go to next editable '''[[#IO_Field| IO_Field]]''', if this is the last editable '''[[#IO_Field| IO_Field]]''' then restart from '''[[#IO_Field | IO_Field]]''' number one.
* For '''UP_KEY''' go to the previous editable '''[[#IO_Field| IO_Field]]''', if there is no previous editable '''[[#IO_Field| IO_Field]]''', go to the last editable '''[[#IO_Field| IO_Field]]''' of the ''IO_Form'' and continue the search for an editable '''[[#IO_Field| IO_Field]]'''.
* For '''ENTER_KEY''' do exactly as '''TAB_KEY''', except that if the current '''[[#IO_Field| IO_Field]]''' is a submitter (is tagged to be a submitter when added), in which case terminate the edit function returning the '''ENTER_KEY'''.
* For any other key, terminate the edit function returning the character which caused the termination.
Inherit IO_Field and IO_Frame into a new class called IO_TextEdit. (Read: Practical Programming Techniques Using C++, pages 94 to 96, Multiple Inheritance topic)
IO_TextEdit, uses the io_edit() function of ciol library if the having its isTextEditor flag set to true(1). IO_TextEdit calls the io_edit function repeatedly to edit series of strings that is created dynamically by the IO_TextEdit. If an initial initially a newline -separated ('\n') separated string is provided, IO_TextEdit will split the string into several strings and copy them into dynamically allocated series of strings.
IO_TextEdit will do the edit in a framed multiline text field. Editing begins with the cursor at the top left of the field or from the position the editing was terminated beforelast time.
Each line can be edited using the io_edit. If during the process of editing the string is shifted, make sure all lines are shifted together. If in overstrike mode hitting the enter key goes to next line. Otherwise (in insert mode) it should insert a new line after the current line and if there is any data after the current position, the data should be cut, and pasted to the newly created line. The cursor should stand at the beginning of the new line.
===void set(const void *str);===
splits the newline separated data from the "str" argument into "series of stingsstrings" that are created dynamically to be edited by the io_edit function in the edit method.
===virtual ~IO_TextEdit();===
bool ValidYear(const char* data, IO_Form& F){
bool res = true;
int i = 0; sscanfatoi(data,"%d",&i);
if( i < 1895 || i > 2010){
res = false;
bool ValidRating(const char*data, IO_Form& F){
bool res = true;
double d = -1.0; sscanfatof(data,"%lf", &d);
if( d<0.0 || d>10 ){
res = false;
'''fardad:''' Done, you can now update you working copy and see what I did. You should do the same for all the other classes. It should not take you more than 30 minutes to do your part, just pick a class and write it.
 
==Compiling under linux==
 
If anyone is actually trying to compile under linux, they will notice quickly it fails.
 
To compile in matrix, use:
 
g++ yada.cpp yadoo.cpp -x c ciol.c -lncurses
 
 
If you have many cpp's, you may also do
 
g++ *.cpp -x c ciol.c -lncurses
3
edits

Navigation menu