MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / CityTemperatureInfo

Function CityTemperatureInfo

Lab_21/city_temperature_control.cpp:201–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199};
200
201void CityTemperatureInfo() {
202
203 CityTemperature Temperature; // creating an object
204
205 for (int i = 0; i < 1000; i++) {
206 system("cls");
207
208 cout << "City Temperature Information: \n";
209 cout << "1. Add\n";
210 cout << "2. Update\n";
211 cout << "3. Delete\n";
212 cout << "0. Go Back\n";
213
214 cout << "Your choice: \n";
215
216 switch (_getch())
217 {
218 case '1': {
219 system("cls");
220 cout << "ADD DATA TO CITY\n";
221 cout << "Enter temperature data of city: " << endl;
222 // Add to List
223 ofstream outTemperature("Temperature", ios::binary | ios::app); // opening a binary file
224 Temperature.setClimateData();
225 // writing data to file
226 outTemperature.write((char*)&Temperature, sizeof(CityTemperature));
227 outTemperature.close();
228
229 system("pause");
230 }break;
231
232 case '2': {
233 system("cls");
234
235 ifstream inP("Temperature", ios::binary);
236 while (inP.read((char*)&Temperature, sizeof(CityTemperature))) {
237 Temperature.getClimateData();
238 }
239 inP.close(); // closing the files after execution
240
241 // searching the city by its ID
242 int ID;
243 cout << "\nEnter ID of city which you want to delete: ";
244 cin >> ID;
245
246 ifstream inTemperature1;
247 inTemperature1.open("Temperature", ios::binary);
248 while (inTemperature1.read((char*)&Temperature, sizeof(CityTemperature))) {
249 if (ID == Temperature.getCityID()) {
250 Temperature.getClimateData();
251 }
252 }
253 inTemperature1.close();
254
255 ofstream inTemperatureTemp1("TemperatureTemp", ios::binary);
256 ifstream inTemperature("Temperature", ios::binary);
257 // reading file
258 while (inTemperature1.read((char*)&Temperature, sizeof(CityTemperature))) {

Callers 1

mainFunction · 0.85

Calls 4

getCityIDMethod · 0.80
mainFunction · 0.70
setClimateDataMethod · 0.45
getClimateDataMethod · 0.45

Tested by

no test coverage detected