summaryrefslogtreecommitdiff
path: root/week_1/review_program/review_program.cpp
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-09-26 22:39:21 -0700
committerFuwn <[email protected]>2023-09-26 22:39:21 -0700
commit826353dfcc7da180e3a92e7d19ad87ae09838b23 (patch)
tree7ff1dee68876a102912559399e7cd746d5b9a799 /week_1/review_program/review_program.cpp
parentstyle(review_program): rename symbols (diff)
downloadcs260-826353dfcc7da180e3a92e7d19ad87ae09838b23.tar.xz
cs260-826353dfcc7da180e3a92e7d19ad87ae09838b23.zip
style(review_program): implement styles
Diffstat (limited to 'week_1/review_program/review_program.cpp')
-rw-r--r--week_1/review_program/review_program.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/week_1/review_program/review_program.cpp b/week_1/review_program/review_program.cpp
index d89d206..e6efe64 100644
--- a/week_1/review_program/review_program.cpp
+++ b/week_1/review_program/review_program.cpp
@@ -1,10 +1,22 @@
+/* review_program.cpp
+ * Summary: Implementation for main program functionality
+ * Test Cases:
+ * - 1221 69.95 30 150 1 1; 4686.65 937.33
+ * - 8392 60 30 150 1 1; 4020 804
+ * - 8392 60 30 150 1 1; 1800 360
+ * - 8392 60 30 100 1 1; 600 120
+ * Author: Zoltan Szabatin
+ * Created: September 26th, 2023
+ */
+
#include "review_program.h"
#include "textbook.h"
#include <cstdint>
#include <iostream>
-namespace ReviewProgram {
+namespace wk1_reviewProgram_zSzabatin {
+
void InputToTextbook(Textbook &textbook) {
// Obtain and set all non-evaluated values for textbook
textbook.SetCode(InputToTextbookValue<uint64_t>("Book"));
@@ -35,7 +47,7 @@ void TextbookInputHandler(std::vector<Textbook> &textbooks) {
// 5. Add textbook to running count
Textbook textbook;
- ReviewProgram::InputToTextbook(textbook);
+ InputToTextbook(textbook);
std::cout << "---" << std::endl;
@@ -55,7 +67,7 @@ void FullTextbookPurchaseSummary(const std::vector<Textbook> &textbooks) {
double total_for_all_books = 0.0;
// Calculate total cost for all books
- for (const auto &textbook : textbooks) {
+ for (const Textbook &textbook : textbooks) {
total_for_all_books += textbook.GetTotalCost();
}
@@ -64,22 +76,23 @@ void FullTextbookPurchaseSummary(const std::vector<Textbook> &textbooks) {
<< std::endl;
std::cout << "Expected profit: $" << total_for_all_books * 0.2 << std::endl;
}
-} // namespace ReviewProgram
+
+} // namespace wk1_reviewProgram_zSzabatin
int main() {
bool run_again = false;
- std::vector<Textbook::Textbook> textbooks;
+ std::vector<wk1_reviewProgram_zSzabatin::Textbook> textbooks;
// Loop until user is done entering textbooks
do {
- ReviewProgram::TextbookInputHandler(textbooks);
+ wk1_reviewProgram_zSzabatin::TextbookInputHandler(textbooks);
std::cout << "Enter 1 to do another book, 0 to stop. ";
std::cin >> run_again;
} while (run_again);
// Print full purchase summary
- ReviewProgram::FullTextbookPurchaseSummary(textbooks);
+ wk1_reviewProgram_zSzabatin::FullTextbookPurchaseSummary(textbooks);
return 0;
}