void AliveOutput::ShowAllProducts( std::vector<Product*> &productsArray ) { con_color(10); std::cout << "\t\t\t\t" << " Alive table " << "\n"; con_color(15); std::cout << (char)201; for (int i = 0; i < 76; ++i) { if(i == 5 || i == 20 || i == 31 || i == 44 || i == 60) std::cout << (char)203; else std::cout << (char)205; } std::cout << (char)187 << std::endl; std::cout << (char)186; std::cout << " " << std::setw(4) << std::left << "Num." << (char)186; std::cout << " " << std::setw(12) << std::left << "Name" << (char)186; std::cout << " " << std::setw(9) << "Quantity" << (char)186; std::cout << " " << std::setw(10) << "Price" << (char)186; std::cout << " " << std::setw(12) << "Color" << (char)186; std::cout << " " << std::setw(14) << "Lifetime day" << (char)186; std::cout << std::endl; std::cout << (char)204; for (int i = 0; i < 76; ++i) { if(i == 5 || i == 20 || i == 31 || i == 44 || i == 60) std::cout << (char)206; else std::cout << (char)205; } std::cout << (char)185 << std::endl; for (unsigned int i = 0; i < productsArray.size(); i++) { std::cout << (char)186; std::cout << " " << std::setw(4) << std::left << i+1 << (char)186; std::cout << " " << std::setw(12) << std::left << dynamic_cast<Alive*>(productsArray[i])->m_name_product << (char)186; std::cout << " " << std::setw(7) << std::left << dynamic_cast<Alive*>(productsArray[i])->m_quantity_product << (char)186; std::cout << " " << std::setw(9) << std::left << dynamic_cast<Alive*>(productsArray[i])->m_price_product << (char)186; std::cout << " " << std::setw(12) << std::left << dynamic_cast<Alive*>(productsArray[i])->m_color << (char)186; std::cout << " " << std::setw(12) << std::left << dynamic_cast<Alive*>(productsArray[i])->m_lifetime_day; std::cout << (char)186; std::cout << std::endl; } std::cout << (char)200; for (int i = 0; i < 76; ++i) { if( i == 5 || i == 20 || i == 31 || i == 44 || i == 60) std::cout << (char)202; else std::cout << (char)205; } std::cout << (char)188 << std::endl; }
int main(int argc, char **argv) { bool succeed = false; char *redirout = (char*)stdout; char *redirerr = (char*)stderr; char *defs = NULL; con_init(); OPTS_OPTION_U16(OPTION_MEMDUMPCOLS) = 16; /* * Command line option parsing commences now We only need to support * a few things in the test suite. */ while (argc > 1) { ++argv; --argc; if (argv[0][0] == '-') { if (parsecmd("redirout", &argc, &argv, &redirout, 1, false)) continue; if (parsecmd("redirerr", &argc, &argv, &redirerr, 1, false)) continue; if (parsecmd("defs", &argc, &argv, &defs, 1, false)) continue; con_change(redirout, redirerr); if (!strcmp(argv[0]+1, "debug")) { OPTS_OPTION_BOOL(OPTION_DEBUG) = true; continue; } if (!strcmp(argv[0]+1, "memchk")) { OPTS_OPTION_BOOL(OPTION_MEMCHK) = true; continue; } if (!strcmp(argv[0]+1, "nocolor")) { con_color(0); continue; } con_err("invalid argument %s\n", argv[0]+1); return -1; } } con_change(redirout, redirerr); succeed = test_perform("tests", defs); stat_info(); return (succeed) ? EXIT_SUCCESS : EXIT_FAILURE; }
void Shop::LoadBalance() { try { std::ifstream fin(BALANCE, std::ios::in); fin.exceptions(std::ifstream::failbit); if (fin.is_open()) { double balance; while (!fin.eof()) { fin >> balance; m_pBalance->SetBalance(balance); } con_color(15); } fin.close(); }
void Shop::SaveBalance() { try { std::ofstream fout(BALANCE, std::ios_base::out | std::ios_base::trunc); fout.exceptions(std::ofstream::failbit); if (fout.is_open()) { fout << m_pBalance->GetBalance(); con_color(15); } fout.close(); } catch(std::ios_base::failure &fail) { std::cout << "Exception opening/writing file: " << fail.what() << std::endl; } }
bool Shop::Run() // находим DLL и сохраняем путь в вектор m_pVectPath, количество DLL - m_nCountLibrary { m_nCountLibrary = 0; WIN32_FIND_DATA f_data; ZeroMemory(&f_data, sizeof(WIN32_FIND_DATA)); HANDLE hFind = NULL; m_pPathNameDLL.clear(); #ifdef _DEBUG hFind = FindFirstFile("../Debug/*.dll", &f_data); // ищем dll в папке Debug по маске *.dll #else hFind = FindFirstFile("../Release/*.dll", &f_data); // ищем dll в папке Realese по маске *.dll #endif if (hFind == INVALID_HANDLE_VALUE) // ищем dll в текущей папке с exe { char pStr[MAX_PATH]; strcpy(pStr, sCurPathToDLL().c_str()); hFind = FindFirstFile(pStr, &f_data); } if(hFind != INVALID_HANDLE_VALUE) { do { m_pPathNameDLL.push_back(f_data.cFileName); m_nCountLibrary++; }while(FindNextFile(hFind, &f_data)); } else { con_color(12); std::cout << "Can't find any DLL!\n"; Sleep(3000); return false; } FindClose(hFind); return true; }
int main(int argc, char **argv) { bool extract = true; char *redirout = (char*)stdout; char *redirerr = (char*)stderr; char *file = NULL; char **files = NULL; pak_file_t *pak = NULL; size_t iter = 0; con_init(); /* * Command line option parsing commences now We only need to support * a few things in the test suite. */ while (argc > 1) { ++argv; --argc; if (argv[0][0] == '-') { if (parsecmd("redirout", &argc, &argv, &redirout, 1, false)) continue; if (parsecmd("redirerr", &argc, &argv, &redirerr, 1, false)) continue; if (parsecmd("file", &argc, &argv, &file, 1, false)) continue; con_change(redirout, redirerr); switch (argv[0][1]) { case 'e': extract = true; continue; case 'c': extract = false; continue; } if (!strcmp(argv[0]+1, "debug")) { OPTS_OPTION_BOOL(OPTION_DEBUG) = true; continue; } if (!strcmp(argv[0]+1, "memchk")) { OPTS_OPTION_BOOL(OPTION_MEMCHK) = true; continue; } if (!strcmp(argv[0]+1, "nocolor")) { con_color(0); continue; } } vec_push(files, argv[0]); } con_change(redirout, redirerr); if (!file) { con_err("-file must be specified for output/input PAK file\n"); vec_free(files); return EXIT_FAILURE; } if (extract) { if (!(pak = pak_open(file, "r"))) { con_err("failed to open PAK file %s\n", file); vec_free(files); return EXIT_FAILURE; } if (!pak_extract_all(pak, "./")) { con_err("failed to extract PAK %s (files may be missing)\n", file); pak_close(pak); vec_free(files); return EXIT_FAILURE; } /* not possible */ pak_close(pak); vec_free(files); stat_info(); return EXIT_SUCCESS; } if (!(pak = pak_open(file, "w"))) { con_err("failed to open PAK %s for writing\n", file); vec_free(files); return EXIT_FAILURE; } for (iter = 0; iter < vec_size(files); iter++) { if (!(pak_insert_one(pak, files[iter]))) { con_err("failed inserting %s for PAK %s\n", files[iter], file); pak_close(pak); vec_free(files); return EXIT_FAILURE; } } /* not possible */ pak_close(pak); vec_free(files); stat_info(); return EXIT_SUCCESS; }