void Box::loadRecorded(int recorded_number){ ifstream recorded_file; recorded_file.open("Info\\Recorded.txt"); for (int i = 0; i < recorded_number; i++) { string name; getline(recorded_file, name); for (int i = 0; i < channels.size(); i++) { if (searchProgram(name, channels[i]) != -1) { //Avalia a data do programa com a data actual if (currentDate.getTotalDate()>channels[i].getPrograms()[searchProgram(name, channels[i])].getDate().getTotalDate()) { bool state = true; channels[i].setProgramState(searchProgram(name, channels[i]), state); } else { bool state = false; channels[i].setProgramState(searchProgram(name, channels[i]), state); } // Copia o programa para o recordList recordList.push_back(channels[i].getPrograms()[searchProgram(name, channels[i])]); } } } }
void Box::updateProgramName(string &programn) { system("CLS"); cout << " _ _ _ " << endl; cout << " / \\ __| |_ ____ _ _ __ ___ ___ __| |" << endl; cout << " / _ \\ / _` \\ \\ / / _` | '_ \\ / __/ _ \\/ _` |" << endl; cout << " / ___ \\ (_| |\\ V / (_| | | | | (_| __/ (_| |" << endl; cout << " /_/ \\_\\__,_| \\_/ \\__,_|_| |_|\\___\\___|\\__,_|" << endl << endl; cout << "\t \t Update a program" << endl << endl << endl; int channel_position = 0; int program_position = 0; string newname; cout << "Insert a new name to this program: "; cin.clear(); cin.ignore(); getline(cin, newname); for (channel_position; channel_position < channels.size(); channel_position++) { program_position = searchProgram(programn, channels[channel_position]); if (program_position != -1) break; } cout << endl << endl << "The name of the program \"" << channels[channel_position].getPrograms()[program_position].getName() << "\""; cout << " was change to \"" << newname << "\""; Sleep(3000); channels[channel_position].setProgramName(newname, program_position); }
void Box::removeProgram(){ int channel_position = 0; int program_position; string programn; cin.ignore(); cin.clear(); cout << "\nInsert a program name: "; getline(cin, programn); for (channel_position; channel_position < channels.size(); channel_position++) { program_position = searchProgram(programn, channels[channel_position]); if (program_position != -1) break; } if (program_position == -1) { cout << endl << endl << "This program doesn't exist." << endl << endl << endl; } else { cout << endl << endl << "The program \"" << channels[channel_position].getPrograms()[program_position].getName(); cout << "\", from the channel \"" << channels[channel_position].getName() << "\", was sucefully removed" << endl << endl << endl; channels[channel_position].removeProgram(channel_position); } }
void Box::SetProgramRecorded() { string name; int aux=-1; int i = 0; cout << "Insert a Program's name: "; cin.clear(); cin.ignore(); getline(cin, name); cout << endl << endl << endl; int existInRecord = false; for (int j = 0; j < recordList.size(); j++) { if (string_to_upper(name) == string_to_upper(recordList[j].getName())) { existInRecord = true; cout << "The program \"" << name << "\", is in the list of recorded programs." << endl << endl << endl << endl; break; } } if (!existInRecord) { for (i; i < channels.size(); i++) { aux = searchProgram(string_to_upper(name), channels[i]); if (aux >= 0) { break; } } if (aux >= 0) { if (compDates(GetCurrentDate(), channels[i].getPrograms()[aux].getDate())) { cout << "The program \"" << channels[i].getPrograms()[aux].getName(); cout << "\", from the channel \"" << channels[i].getName() << "\", was sucefully\n"; cout << "set to be recorded." << endl << endl << endl << endl; recordList.push_back(channels[i].getPrograms()[aux]); } else { cout << "The program \"" << channels[i].getPrograms()[aux].getName(); cout << "\", from the channel \"" << channels[i].getName() << "\", has been reproduced." << endl << endl << endl << endl; } } else cout << "The program \"" << name << "\" doesn't exist." << endl << endl << endl << endl; } }
bool Box::updateProgram(string &programn){ int channel_position = 0; int program_position = 0; for (channel_position; channel_position < channels.size(); channel_position++) { program_position = searchProgram(programn, channels[channel_position]); if (program_position != -1) break; } if (program_position == -1) { return false; } else return true; }
void Box::updateProgramDuration(string &programn) { system("CLS"); cout << " _ _ _ " << endl; cout << " / \\ __| |_ ____ _ _ __ ___ ___ __| |" << endl; cout << " / _ \\ / _` \\ \\ / / _` | '_ \\ / __/ _ \\/ _` |" << endl; cout << " / ___ \\ (_| |\\ V / (_| | | | | (_| __/ (_| |" << endl; cout << " /_/ \\_\\__,_| \\_/ \\__,_|_| |_|\\___\\___|\\__,_|" << endl << endl; cout << "\t \t Update a program" << endl << endl << endl; int channel_position = 0; int program_position = 0; int newdur; cout << "Insert a new duration to this program: "; cin >> newdur; for (channel_position; channel_position < channels.size(); channel_position++) { program_position = searchProgram(programn, channels[channel_position]); if (program_position != -1) break; } Channel * channel_pointer; channel_pointer = &channels[channel_position]; Program oldp(channels[channel_position].getPrograms()[program_position]); Program newp(channels[channel_position].getPrograms()[program_position]); newp.setDuration(newdur); channels[channel_position].removeProgram(program_position); if (!checkProgramDate(oldp.getDate(), newdur, *channel_pointer)) { channels[channel_position].addProgram(oldp); cout << endl << "Error. The exhibition time matches the exhibition time of an \n"; cout << "already existing program.\n \nPlease enter different values\n"; Sleep(3000); } else { channels[channel_position].addProgram(newp); cout << endl << endl << "The duration of the program \"" << newp.getName() << "\""; cout << " was change to \"" << newdur << "\""; Sleep(3000); } }
__MSSHELL_WRAPPER_ static void _MS__private __system showUsage(const sel_typ argc, char ** argv) { if(argc) { const sprog * const prog = searchProgram(argv[0]); if(prog) _showUsage(prog); else printErr(1, "SubProgram inserted CmdName hasn't been found into Programs Macro-List"); return; } printf2("\n\n*** Program MACRO-LIST ***\n"); SHOWPAUSEMESSAGE(); PRINTL(); dim_typ i; for(i=0; i<MAX_PROGRAMMI; ++i) { _showUsage(&main_menu[i]); if(catchPause()) return; } for(i=0; i<MAX_ADVCALC_PROGS; ++i) { _showUsage(&adv_calc[i]); if(catchPause()) return; } for(i=0; i<MAX_ALGEBRA_OPERATIONS; ++i) { _showUsage(&alg_operations[i]); if(catchPause()) return; } return; }
void Box::updateProgramState(string &programn) { system("CLS"); cout << " _ _ _ " << endl; cout << " / \\ __| |_ ____ _ _ __ ___ ___ __| |" << endl; cout << " / _ \\ / _` \\ \\ / / _` | '_ \\ / __/ _ \\/ _` |" << endl; cout << " / ___ \\ (_| |\\ V / (_| | | | | (_| __/ (_| |" << endl; cout << " /_/ \\_\\__,_| \\_/ \\__,_|_| |_|\\___\\___|\\__,_|" << endl << endl; cout << "\t \t Update a program" << endl << endl << endl; int channel_position = 0; int program_position = 0; for (channel_position; channel_position < channels.size(); channel_position++) { program_position = searchProgram(programn, channels[channel_position]); if (program_position != -1) break; } if (compDates(GetCurrentDate(), channels[channel_position].getPrograms()[program_position].getDate())) { cout << "The program \"" << channels[channel_position].getPrograms()[program_position].getName() << "\""; cout << " wasn't reproduced yet"; Sleep(3000); } else { cout << endl << endl << "The record state of the program \"" << channels[channel_position].getPrograms()[program_position].getName() << "\""; cout << " was change to \""; if (channels[channel_position].getPrograms()[program_position].getState()) cout << "true"; else cout << "false"; cout << "\""; Sleep(3000); channels[channel_position].setProgramState(program_position); } }
bool Box::RecordProgram(string &program_name, string &channel_name){ int channel_loc = searchChannel(channel_name); Channel * channel = &channels[channel_loc]; int program = searchProgram(program_name, *channel); for (int i = 0; i < recordList.size(); i++) { if (channel->getPrograms()[program].getName()==recordList[i].getName()) { return false; } } if (currentDate.getTotalDate() > channel->getPrograms()[program].getDate().getTotalDate()) { bool state = true; channel->getPrograms()[program].setRecord(state); } recordList.push_back(channel->getPrograms()[program]); saveChannels(); saveRecorded(); return true; }
bool Box::createdProgram(string &channel){ Channel * channel_pointer; channel_pointer = &Channel(channel); // Esta linha serve para o programa não dar erro porque existe a possibilidade de o apontador não ser inicializado for (int i = 0; i < channels.size(); i++) { if (channels[i].getName()==channel) { channel_pointer = &channels[i]; } } system("CLS"); string new_program; cout << " _ _ _ " << endl; cout << " / \\ __| |_ ____ _ _ __ ___ ___ __| |" << endl; cout << " / _ \\ / _` \\ \\ / / _` | '_ \\ / __/ _ \\/ _` |" << endl; cout << " / ___ \\ (_| |\\ V / (_| | | | | (_| __/ (_| |" << endl; cout << " /_/ \\_\\__,_| \\_/ \\__,_|_| |_|\\___\\___|\\__,_|" << endl << endl; cout << "\t \t Create a program" << endl << endl; cout << endl << "Program name: "; getline(cin, new_program); if (-1 != searchProgram(new_program, *channel_pointer)) { cout << endl << endl << "This name is already in use by another program."; Sleep(2000); createdProgram(channel); } int duration, hour, min; string type, day; ///////////////////////////////////////////// // VERIFICAR A COMPATIBILIDADE DE HORÁRIOS // // // ///////////////////////////////////////////// Date new_program_date = Date(); cout << endl << endl << "Insert the program specifications:\n \n"; //INSERIR DURACAO cout << "Duration(in minutes): "; cin >> duration; while (cin.fail() || duration < 1) { cin.clear(); cin.ignore(10000, '\n'); cout << "Wrong format. Please insert a number equal or bigger then 1.\n"; cout << "Duration(in minutes): "; cin >> duration; } //INSERIR HORA INÍCIO cout << "Starting hour: "; cin >> hour; while (cin.fail() || hour > 23 || hour < 0) { cin.clear(); cin.ignore(10000, '\n'); cout << "Wrong format. Please insert a number between 0 and 23."; cout << "\nStarting hour: "; cin >> hour; } // INSERIR MINUTOS cout << "Starting minutes: "; cin >> min; while (cin.fail() || min > 59 || min < 0) { cin.clear(); cin.ignore(10000, '\n'); cout << "Wrong format. Please insert a number between 0 and 59."; cout << "\nStarting minutes: "; cin >> min; } // INSERIR DIA DA SEMANA int option; cout << "\n1.Sunday\n2.Monday\n3.Tuesday\n4.Wednesday\n5.Thursday\n6.Friday\n7.Saturday\n"; cout << "Choose a day of the week : "; cin >> option; while (cin.fail() || option < 1 || option > 7) { cin.clear(); cin.ignore(10000, '\n'); cout << "Option mismatch. Please choose a number between 1 and 7: "; cin >> option; } day = new_program_date.getStr(option); new_program_date.setDate(day, hour, min); if (!checkProgramDate(new_program_date, duration, *channel_pointer)) { cout << endl << "Error. The exhibition time matches the exhibition time of an already existing program.\nPlease enter different values\n"; Sleep(2000); createdProgram(channel); } // ADICIONAR TIPO DE PROGRAMA cout << "\nProgram Type: "; cin.clear(); cin.ignore(1000, '\n'); cin >> type; bool recorded = false; // ADICIONAR Programa channel_pointer->addProgram(new_program, duration, type, recorded, day, hour, min); saveChannels(); return true; }
void Box::updateProgramDate(string &programn) { system("CLS"); cout << " _ _ _ " << endl; cout << " / \\ __| |_ ____ _ _ __ ___ ___ __| |" << endl; cout << " / _ \\ / _` \\ \\ / / _` | '_ \\ / __/ _ \\/ _` |" << endl; cout << " / ___ \\ (_| |\\ V / (_| | | | | (_| __/ (_| |" << endl; cout << " /_/ \\_\\__,_| \\_/ \\__,_|_| |_|\\___\\___|\\__,_|" << endl << endl; cout << "\t \t Update a program" << endl << endl << endl; int channel_position = 0; int program_position = 0; int hour, min; string day; Date new_program_date = Date(); //INSERIR HORA INÍCIO cout << "New starting hour: "; cin >> hour; while (cin.fail() || hour > 23 || hour < 0) { cin.clear(); cin.ignore(10000, '\n'); cout << "Wrong format. Please insert a number between 0 and 23."; cout << "\nNew starting hour : "; cin >> hour; } // INSERIR MINUTOS cout << "New starting minutes: "; cin >> min; while (cin.fail() || min > 59 || min < 0) { cin.clear(); cin.ignore(10000, '\n'); cout << "Wrong format. Please insert a number between 0 and 59."; cout << "\nNew starting minutes: "; cin >> min; } // INSERIR DIA DA SEMANA int option; cout << "\n1.Sunday\n2.Monday\n3.Tuesday\n4.Wednesday\n5.Thursday\n6.Friday\n7.Saturday\n"; cout << "Choose a day of the week: "; cin >> option; while (cin.fail() || option < 1 || option > 7) { cin.clear(); cin.ignore(10000, '\n'); cout << "Option mismatch. Please choose a number between 1 and 7: "; cin >> option; } day = new_program_date.getStr(option); for (channel_position; channel_position < channels.size(); channel_position++) { program_position = searchProgram(programn, channels[channel_position]); if (program_position != -1) break; } Channel * channel_pointer; channel_pointer = &channels[channel_position]; Program oldp(channels[channel_position].getPrograms()[program_position]); Program newp(channels[channel_position].getPrograms()[program_position]); newp.setDate(day, hour, min); channels[channel_position].removeProgram(program_position); if (!checkProgramDate(newp.getDate(), oldp.getDuration(), *channel_pointer)) { channels[channel_position].addProgram(oldp); cout << endl << "Error. The exhibition time matches the exhibition time of an \n"; cout << "already existing program.\n \nPlease enter different values\n"; Sleep(3000); } else { channels[channel_position].addProgram(newp); cout << endl << endl << "The date of the program \"" << newp.getName() << "\""; cout << " was change to \""; newp.getDate().showDate(); cout << "\""; Sleep(3000); } }