Hi,
If you really have time to help a newbie
I am new to
java programming, and my mind still with the old structured programming. I do understand about object, inheritance, polymorphic, method, interface, abstract data type. But, when it comes to EVENT handling, I lost
Usually in structured programing, you can follow the flow.
So, in order to be more understand, could you please give me some VERY simple (easy to understand) example code to do :
// this is just a generic algorithm
main_program () {
repeat
write "1 = sub1";
write "2 = sub2";
write "0 = exit program";
key = get_a_key ();
if (key = "1") { sub_program1 (); }
if (key = "2") { sub_program2 ("HELLO"); }
until key = "0";
exit(); // exit program
}
sub_program1 () {
b = 0;
repeat
a = 0;
repeat
c = get_keypressed;
write a; // flood the screen with number
a = a + 1;
until c = <exit_key>;
write b;
b = b + 1;
until b = 3;
return; // go back to main program
}
sub_program2 (s) {
write s;
return;
}
My objective here is to learn how to call a subprogram, and designing event handler in object oriented way.
thanks,