| 337 | } |
| 338 | |
| 339 | void CityRainFallInfo() { |
| 340 | |
| 341 | CityRainFall R; |
| 342 | |
| 343 | for (int i = 0; i < 1000; i++) { |
| 344 | system("cls"); |
| 345 | |
| 346 | cout << "City RainFall Information: \n"; |
| 347 | cout << "1. Add\n"; |
| 348 | cout << "2. Update\n"; |
| 349 | cout << "3. Delete\n"; |
| 350 | cout << "4. Displaying all\n"; |
| 351 | cout << "0. Go Back\n"; |
| 352 | |
| 353 | cout << "Your choice: \n"; |
| 354 | |
| 355 | switch (_getch()) |
| 356 | { |
| 357 | case '1': { |
| 358 | system("cls"); |
| 359 | cout << "ADD DATA TO CITY\n"; |
| 360 | cout << "Enter RainFall data of city: " << endl; |
| 361 | // Add to List |
| 362 | ofstream outR("R", ios::binary | ios::app); |
| 363 | R.setClimateData(); |
| 364 | outR.write((char*)&R, sizeof(CityRainFall)); |
| 365 | outR.close(); |
| 366 | |
| 367 | system("pause"); |
| 368 | }break; |
| 369 | |
| 370 | case '2': { |
| 371 | system("cls"); |
| 372 | |
| 373 | ifstream inP("R", ios::binary); |
| 374 | while (inP.read((char*)&R, sizeof(CityRainFall))) { |
| 375 | R.getClimateData(); |
| 376 | } |
| 377 | inP.close(); // closing the files after execution |
| 378 | |
| 379 | // searching the city by its ID |
| 380 | int ID; |
| 381 | cout << "\nEnter ID of city which you want to delete: "; |
| 382 | cin >> ID; |
| 383 | |
| 384 | ifstream inR1; |
| 385 | inR1.open("R", ios::binary); |
| 386 | while (inR1.read((char*)&R, sizeof(CityRainFall))) { |
| 387 | if (ID == R.getCityID()) { |
| 388 | R.getClimateData(); |
| 389 | } |
| 390 | } |
| 391 | inR1.close(); |
| 392 | |
| 393 | ofstream inRTemp1("RTemp", ios::binary); |
| 394 | ifstream inR("R", ios::binary); |
| 395 | while (inR1.read((char*)&R, sizeof(CityRainFall))) { |
| 396 | if (ID != R.getCityID()) { |
no test coverage detected