Changes

Jump to: navigation, search

OOP344 Assignment Two

3,541 bytes added, 02:58, 5 November 2009
Sample Main
==Sample Main==
<big><pre>
#include "io_def.h"
#include "io_form.h"
#include "io_label.h"
#include "io_edit.h"
#include "io_vedit.h"
#include <string.h>
#include <stdio.h>
bool ValidYear(const char* data, IO_Form& F){
bool res = true;
int i = 0;
sscanf(data,"%d",&i);
if( i < 1895 || i > 2010){
res = false;
F[4].set("Invlalid");
}
else{
res = true;
F[4].set("");
}
F[4].display();
return res;
}
bool ValidRating(const char*data, IO_Form& F){
bool res = true;
double d = -1.0;
sscanf(data,"%lf", &d);
if( d<0.0 || d>10 ){
res = false;
F[6].set("Invlalid");
}
else{
res = true;
F[6].set("");
}
F[6].display();
return res;
}
void YearHelp(MessageStatus m, IO_Form& F){
if(m == SetMessage){
F.setHelp("years valid between 1895 and 2010");
}
else{
F.setHelp("");
}
F.display(IO_SHOW_HELP);
}
void RateHelp(MessageStatus m, IO_Form& F){
if(m == SetMessage){
F.setHelp("Numbers between 0.0 and 10");
}
else{
F.setHelp("");
}
F.display(IO_SHOW_HELP);
}
 
int main(void){
io_init();
int insert = 1;
char str[51] = "testing this";
IO_Form F(true, 1, 3, 70,21 );
F <<new IO_Label("| Movie Information Entry |", 0, 3)
<<new IO_Label("Name:", 2,2)<<new IO_Label("Director:", 5, 2)
<<new IO_Label("Release Date:", 8, 2)<<new IO_Label(8, 21, 10)
<<new IO_Label("User rating 1->10:", 11, 2)<<new IO_Label(11, 25, 10)
<<new IO_Label("Classification:", 14, 2)
<<new IO_Label("Gnere:", 2, 36)
<<new IO_Label("Commnet:", 13, 29)
<<new IO_Edit(1, 7, 15, 25, &insert, true, _FRAME_UNDERLINE)
<<new IO_Edit(4, 11, 15, 30, &insert, true, _FRAME_UNDERLINE)
<<new IO_Vedit(7,15, 5, 4, &insert, true, ValidYear, YearHelp, _FRAME_UNDERLINE)
<<new IO_Vedit(10,20,4, 3, &insert, true, ValidRating, RateHelp, _FRAME_UNDERLINE);
F.addHelp(new IO_Label(19,2, 60));
F.edit();
io_end();
return 0;
};
</pre></big>
 
Screen Shot of the above program:
 
<big><pre>
+--| Movie Information Entry |---------------------------------------+
| |
| Name: Gnere: |
| --------------- |
| |
| Director: |
| --------------- |
| |
| Release Date: |
| ----- |
| |
| User rating 1->10: |
| ---- |
| Commnet: |
| Classification: |
| |
| |
| |
| |
| |
+--------------------------------------------------------------------+
</pre></big>
 
==IO_Form==

Navigation menu