void Programme::addSubElement( QDomElement &element) { if(element.localName().compare("Icon", Qt::CaseInsensitive)==0) { Icon *cn = Icon::fromElement(element); addIcon(cn); return; } if(element.localName().compare("Category", Qt::CaseInsensitive)==0) { Category *cn = Category::fromElement(element); addCategory(cn); return; } if(element.localName().compare("SubTitle", Qt::CaseInsensitive)==0) { SubTitle *cn = SubTitle::fromElement(element); addSubTitle(cn); return; } if(element.localName().compare("LastChance", Qt::CaseInsensitive)==0) { LastChance *cn = LastChance::fromElement(element); addLastChance(cn); return; } if(element.localName().compare("Audio", Qt::CaseInsensitive)==0) { Audio *cn = Audio::fromElement(element); addAudio(cn); return; } if(element.localName().compare("Subtitles", Qt::CaseInsensitive)==0) { Subtitles *cn = Subtitles::fromElement(element); addSubtitles(cn); return; } if(element.localName().compare("Date", Qt::CaseInsensitive)==0) { Date *cn = Date::fromElement(element); addDate(cn); return; } if(element.localName().compare("PreviouslyShown", Qt::CaseInsensitive)==0) { PreviouslyShown *cn = PreviouslyShown::fromElement(element); addPreviouslyShown(cn); return; } if(element.localName().compare("Country", Qt::CaseInsensitive)==0) { Country *cn = Country::fromElement(element); addCountry(cn); return; } if(element.localName().compare("OrigLanguage", Qt::CaseInsensitive)==0) { OrigLanguage *cn = OrigLanguage::fromElement(element); addOrigLanguage(cn); return; } if(element.localName().compare("StarRating", Qt::CaseInsensitive)==0) { StarRating *cn = StarRating::fromElement(element); addStarRating(cn); return; } if(element.localName().compare("Credits", Qt::CaseInsensitive)==0) { Credits *cn = Credits::fromElement(element); addCredits(cn); return; } if(element.localName().compare("Title", Qt::CaseInsensitive)==0) { Title *cn = Title::fromElement(element); addTitle(cn); return; } if(element.localName().compare("Video", Qt::CaseInsensitive)==0) { Video *cn = Video::fromElement(element); addVideo(cn); return; } if(element.localName().compare("New", Qt::CaseInsensitive)==0) { New *cn = New::fromElement(element); addNew(cn); return; } if(element.localName().compare("Rating", Qt::CaseInsensitive)==0) { Rating *cn = Rating::fromElement(element); addRating(cn); return; } if(element.localName().compare("EpisodeNum", Qt::CaseInsensitive)==0) { EpisodeNum *cn = EpisodeNum::fromElement(element); addEpisodeNum(cn); return; } if(element.localName().compare("Length", Qt::CaseInsensitive)==0) { Length *cn = Length::fromElement(element); addLength(cn); return; } if(element.localName().compare("Url", Qt::CaseInsensitive)==0) { Url *cn = Url::fromElement(element); addUrl(cn); return; } if(element.localName().compare("Review", Qt::CaseInsensitive)==0) { Review *cn = Review::fromElement(element); addReview(cn); return; } if(element.localName().compare("Language", Qt::CaseInsensitive)==0) { Language *cn = Language::fromElement(element); addLanguage(cn); return; } if(element.localName().compare("Premiere", Qt::CaseInsensitive)==0) { Premiere *cn = Premiere::fromElement(element); addPremiere(cn); return; } if(element.localName().compare("Desc", Qt::CaseInsensitive)==0) { Desc *cn = Desc::fromElement(element); addDesc(cn); return; } }
countries::countries(string countryName, double pprice, double vat) { addCountry(countryName, pprice, vat); }
void readFromFile(FILE *file, FILE *fileOutput) { int N; fscanf (file, "%d", &N); printf ("N=%d\n", N); int totalLifeOfSentinels = 0; int value; int i; for(i=0; i<N; i++) { fscanf(file, "%d", &value); totalLifeOfSentinels = totalLifeOfSentinels + value; addLast(value); } printf("%d\n", totalLifeOfSentinels); printAll(fileOutput); int countryNumber; fscanf(file, "%d", &countryNumber); printf ("countryNumber=%d\n", countryNumber); /*!***************************************************************************** * DECLARATION ZONE ********************************************************************************/ char line[1000]; //for each line value = 0; int ok = 0; int lifeOfaCountry = 0; int totalLifeOfCountries = 0; int maxLife = 0, minLife = 9999; char mostPowerfulCountry[100], weakestCountry[100], thePowerfulOfThemAll[100]; node *strongestCountry; // /*!*****************************************************************************+ * END OF THE DECLARATION ZONE ********************************************************************************/ fgets(line, sizeof(line), file); int k; for(k=0; k<countryNumber; k++) { fgets(line, sizeof(line), file); char *tok = strtok(line, " \n"); printf("\n%s: ", tok); addCountry(tok); listOfLists *currentCountry = head; // move pointer to current country while (currentCountry->next != NULL) { currentCountry = currentCountry->next; } while((tok = strtok(NULL, " ")) != NULL) //I skip the counties, and tok will be first - the first value-element of China and so on { printf("%s ", tok); value = atoi(tok); lifeOfaCountry = lifeOfaCountry + value; addWaves(fileOutput,value,currentCountry); } totalLifeOfCountries = totalLifeOfCountries + lifeOfaCountry; if(maxLife<lifeOfaCountry) { maxLife=lifeOfaCountry; strcpy(mostPowerfulCountry,currentCountry->countryName); strongestCountry = currentCountry->nextWave; } if(minLife>lifeOfaCountry) { minLife=lifeOfaCountry; strcpy(weakestCountry,currentCountry->countryName); } if(lifeOfaCountry>totalLifeOfSentinels) { ok = 1; strcpy(thePowerfulOfThemAll, head->countryName); } lifeOfaCountry=0; } fprintf(fileOutput, "\nThe strongest country was: %s\n", mostPowerfulCountry); fprintf(fileOutput, "The weakest country was: %s\n", weakestCountry); if(ok==1) { fprintf(fileOutput, "%s could have defeated all the sentinels.\n",thePowerfulOfThemAll); } else { fprintf(fileOutput, "No country could have defeated all the sentinels\n"); sentinelsDown(fileOutput, maxLife, mostPowerfulCountry); } if(totalLifeOfSentinels<totalLifeOfCountries) { fprintf(fileOutput,"The tyrant was killed!\n"); lastHit(fileOutput, totalLifeOfSentinels ); } else { fprintf(fileOutput,"The tyrant was not killed!\n"); } }