-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.cpp
59 lines (48 loc) · 1.82 KB
/
functions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "header.h"
using namespace std;
/*
Piotr Pietrusewicz 53828 120A
West Pomeranian University of Technology
Theme: Car Dealearship
File that contains some of the functions used in the other files
*/
// Writing to a file using the overloaded operator '<<' for a 'Dealership' object
void saveToAFile(Dealership& dealership) {
std::ofstream outFile("Dealership.txt");
// Write data to the file from the dealership object
outFile << dealership;
cout << "\n" << setfill('=') << setw(68) << "=\n\n";
cout << " Data has been saved into the 'Dealership.txt' file\n\n";
cout << " Press ENTER to go back to the menu\n";
cout << "\n" << setfill('=') << setw(67) << "=\n";
cin.ignore();
cin.get();
}
// Reading data from a file using the overloaded operator '>>' for a 'Dealership' object
void loadDataFromAFile(Dealership& dealership) {
std::ifstream inFile("Dealership.txt");
// Read data from the file into the dealership object
inFile >> dealership;
cout << "\n" << setfill('=') << setw(68) << "=\n\n";
cout << " Data has been updated from the 'Dealership.txt' file\n\n";
cout << " Press ENTER to go back to the menu\n";
cout << "\n" << setfill('=') << setw(67) << "=\n";
cin.ignore();
cin.get();
}
// Functions that handle repeated outputs to the terminal
void displayIncorrectNumberMessage() {
cout << "\n" << setfill('=') << setw(70) << "=\n\n";
cout << " An incorrect number has been entered\n\n";
cout << " Press ENTER to go back to the menu\n";
cout << "\n" << setfill('=') << setw(69) << "=\n";
cin.ignore();
cin.get();
}
void displayPressEnterToMenu() {
cout << "\n" << setfill('=') << setw(70) << "=\n\n";
cout << " Press ENTER to go back to the menu\n";
cout << "\n" << setfill('=') << setw(69) << "=\n";
cin.ignore();
cin.get();
}