List (522775), страница 2
Текст из файла (страница 2)
Intercept standart input.print_welcome(); //Show welcome messagechar command[SIZE_OF_COMMAND]; //Type of commandchar buff[SIZE_OF_COMMAND]; //Bufferint h_buff; //Hash value of buffer (cached)while (1) {cout<<"\n=>"; //Default markcin>>command;h_buff=hash(command);if (h_buff==h_add) {cin>>buff;if (hash(buff)==h_to) {int pos;char a;char b;char c;char d;cin>>pos>>a>>b>>c>>d;(*list).add(pos,a,b,c,d);}else{char a;char b;char c;char d;cin>>b>>c>>d;a=buff[0];(*list).add(a,b,c,d);}}if (h_buff==h_upd) {cin>>buff;if (hash(buff)==h_to) {int pos;char a;char b;char c;char d;cin>>pos>>a>>b>>c>>d;(*list).update(pos,a,b,c,d);}else{char a;char b;char c;char d;cin>>b>>c>>d;a=buff[0];(*list).update(a,b,c,d);}}if (h_buff==h_get) {char a;Задание #2 - Листинги - File: console.cpp /страница 10 из 12/}char b;char c;char d;(*list).get(a,b,c,d);cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\n";if (h_buff==h_print) {(*list).print();}if (h_buff==h_empty) {if ((*list).empty())cout<<"Is empty\n";elsecout<<"Not empty\n";}if (h_buff==h_xch) {int pos;cin>>pos;(*list).exchange(pos);}if (h_buff==h_rwd) {int pos;cin>>pos;(*list).rewind(pos);}if (h_buff==h_rwdto) {int pos;cin>>pos;(*list).rewindto(pos);}if (h_buff==h_del) {(*list).del();}if (h_buff==h_delin) {int pos;cin>>pos;(*list).del(pos);}if (h_buff==h_cnt) {cout<<"Nodes count: "<<(*list).count()<<"\n";}if (h_buff==h_help) {cout<<"ME Console of List emulator help\nDefaul commands:\n"<<"add <> <> <> <> - add new node\n"<<"add to <i> <> <> <> <> - add new node to <i> position\n"<<"del - delete active node\n"<<"delin <i> - delete <i> node\n"<<"xch <i> - exchange <i> and <i+1> node position\n"<<"rwd <i> - rewind on position\n"<<"rwdto <i> - set mark on <i> position\n"<<"print - print nodes of list\n"<<"empty - is list empty?\n"<<"get - get values of active node\n"<<"cnt - get count of nodes\n"<<"upd <> <> <> <> - update active node\n"<<"upd to <i> <> <> <> <> - update node in <i> position\n"<< "help - print this screen\n"<<"exit - leave this emulator\n";}if (h_buff==h_exit) {print_goodbye();return;}}}Задание #2 - Листинги - File: console.cpp /страница 11 из 12/Test: run commandsME console has initedWelcome to ME console of List emulatorRun commands:=>helpME Console of List emulator helpDefaul commands:add <> <> <> <> - add new nodeadd to <i> <> <> <> <> - add new node to <i>positiondel - delete active nodedelin <i> - delete <i> nodexch <i> - exchange <i> and <i+1> nodepositionrwd <i> - rewind on positionrwdto <i> - set mark on <i> positionprint - print nodes of listempty - is list empty?get - get values of active nodecnt - get count of nodesupd <> <> <> <> - update active nodeupd to <i> <> <> <> <> - update node in <i>positionhelp - print this screenexit - leave this emulator=>add 1 1 1 a=>add 2 2 2 b=>add 3 3 3 c=>add 4 4 4 d=>print111a222b333c444d=>add to 1 i i i i=>print111aiiii222b333c444d=>xch 1=>print111a222biiii333c444d=>xch 4=>print111a444d222biiii333c=>xch 0=>print444d111a222biiii333c=>add to 0 x x x x=>printxxxx444d111a222biiii333c=>rwdto 0=>getxxx=>rwd -2=>getiii=>rwd 3=>get444=>upd u u u u=>printxxxuuu111222iii333=>upd to 4 r r r r=>printxxxuuu111222rrr333=>cntNodes count: 6=>emptyNot empty=>del=>printuuu111222rrr333=>delin 0=>print111222rrr333=>del=>del=>del=>del=>delME List: List is empty=>add m e w s=>add l i s t=>printmewlis=>delin 0=>delin 0=>printThere no items=>emptyIs empty=>cntNodes count: 0=>add w w w w=>printwww=>exitBye Bye!xidxuabicxuabrcuabrcabrcstw<*with bold – user commands>Задание #2 - Листинги - Test: run commands /страница 12 из 12/.