-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
85 lines (62 loc) · 2.78 KB
/
main.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>
#include "CoffeeTracking.hpp"
#include <fstream>
/*
//ESPRESSO EXPENSE CALCULATOR//
Welcome to the Espresso Expense Calculator, a handy tool designed to simplify the management of coffee orders and expenses within groups or teams.
Whether you're organizing office coffee runs or tracking coffee expenses among friends, this application streamlines the process for you.
The algorithm dynamically tracks participants' spending on other people's coffee orders and selects the individual who has spent the least on others as the next coffee buyer.
Getting Started
The build process is nothing out of the ordinary for a C++ application:
Clone the Repository: Clone the repository to your local machine using the following command:
git clone https://github.com/JustinCosta10/Espresso-Expense-Calculator
Build the Application: Build the application using your preferred C++ compiler. For example, using clang:
clang++ main.cpp -std=c++17 CoffeeTracking.cpp -o EspressoExpense
Run the Program: Execute the compiled binary to launch the Espresso Expense Calculator:
./EspressoExpense
*/
int MainMenuChoice();
int main()
{
bool programActive = true; //used to exit program safely.
CoffeeTracking coffeeTime; //creates object of the class CoffeeTracking that allows reading,writing and sorting of the coffee orders.
do
{
std::cout << "\n\nESPRESSO EXPENSE CALCULATOR\n\n";
coffeeTime.ReadData();
coffeeTime.DisplayOrders();
switch (MainMenuChoice())
{
case 'a':
coffeeTime.EditCoffeeOrder(); // Allows user to edit the order, coffee name and price. Writes to orderdata.csv
break;
case 'b':
coffeeTime.OrderCoffee(); //Orders coffee and keeps track of who has spent what. Sorts by amount spent on the other people's orders.
break;
case 'c':
std::cout << "Exiting...\n\n"; // exits program
programActive = false;
break;
}
coffeeTime.Orders.clear();
} while (programActive);
} // end main
int MainMenuChoice() // displays initial menu options and validates user input of a valid character.
{
char userMenuChoice;
const int MENU_OPTIONS = 4;
std::cout << "\n\na. Edit a Coffee Order\n";
std::cout << "b. Order Coffee\n";
std::cout << "c. Exit\n\n";
std::cout << "Select a letter option (a, b, or c): ";
std::cin >> userMenuChoice;
while (userMenuChoice < 'a' || userMenuChoice > 'c' || std::cin.fail())
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "Please enter a valid option.\n";
std::cout << "Select a letter option (a, b, or c): ";
std::cin >> userMenuChoice;
}
return userMenuChoice;
}