summaryrefslogtreecommitdiff
path: root/week_1/review_program/textbook.cpp
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-09-26 22:14:57 -0700
committerFuwn <[email protected]>2023-09-26 22:14:57 -0700
commit199ec09e5b1ab397acf36c192d1e381a89083be8 (patch)
tree29d9f70ca0a963df7f49bb387b290b5675a7d7b7 /week_1/review_program/textbook.cpp
parentstyle(review_program): move main function order (diff)
downloadcs260-199ec09e5b1ab397acf36c192d1e381a89083be8.tar.xz
cs260-199ec09e5b1ab397acf36c192d1e381a89083be8.zip
style(review_program): rename symbols
Diffstat (limited to 'week_1/review_program/textbook.cpp')
-rw-r--r--week_1/review_program/textbook.cpp63
1 files changed, 27 insertions, 36 deletions
diff --git a/week_1/review_program/textbook.cpp b/week_1/review_program/textbook.cpp
index dfca4cd..fe39be4 100644
--- a/week_1/review_program/textbook.cpp
+++ b/week_1/review_program/textbook.cpp
@@ -3,51 +3,42 @@
#include <iomanip>
#include <iostream>
-namespace textbook {
-auto Textbook::code() const -> uint64_t { return this->_code; }
-auto Textbook::single_copy_price() const -> double {
- return this->_single_copy_price;
-}
-auto Textbook::number_on_hand() const -> uint64_t {
- return this->_number_on_hand;
-}
-auto Textbook::prospective_enrollment() const -> uint64_t {
+namespace Textbook {
+uint64_t Textbook::GetCode() const { return this->_code; }
+double Textbook::GetSingleCopyPrice() const { return this->_single_copy_price; }
+uint64_t Textbook::GetNumberOnHand() const { return this->_number_on_hand; }
+uint64_t Textbook::GetProspectiveEnrollment() const {
return this->_prospective_enrollment;
}
-auto Textbook::required() const -> bool { return this->_required; }
-auto Textbook::used() const -> bool { return this->_used; }
-auto Textbook::amount_to_order() const -> uint64_t {
- return this->_amount_to_order;
-}
-auto Textbook::total_cost() const -> double { return this->_total_cost; }
+bool Textbook::GetIsRequired() const { return this->_is_required; }
+bool Textbook::GetIsUsed() const { return this->_is_used; }
+uint64_t Textbook::GetAmountToOrder() const { return this->_amount_to_order; }
+double Textbook::GetTotalCost() const { return this->_total_cost; }
-auto Textbook::set_code(uint64_t code) -> void { this->_code = code; }
-auto Textbook::set_single_copy_price(double single_copy_price) -> void {
+void Textbook::SetCode(uint64_t code) { this->_code = code; }
+void Textbook::SetSingleCopyPrice(double single_copy_price) {
this->_single_copy_price = single_copy_price;
}
-auto Textbook::set_number_on_hand(uint64_t number_on_hand) -> void {
+void Textbook::SetNumberOnHand(uint64_t number_on_hand) {
this->_number_on_hand = number_on_hand;
}
-auto Textbook::set_prospective_enrollment(uint64_t prospective_enrollment)
- -> void {
+void Textbook::SetProspectiveEnrollment(uint64_t prospective_enrollment) {
this->_prospective_enrollment = prospective_enrollment;
}
-auto Textbook::set_required(bool required) -> void {
- this->_required = required;
-}
-auto Textbook::set_used(bool used) -> void { this->_used = used; }
+void Textbook::SetIsRequired(bool required) { this->_is_required = required; }
+void Textbook::SetIsUsed(bool used) { this->_is_used = used; }
-auto Textbook::print() const -> void {
+void Textbook::Print() const {
// Pretty print all values, minus evaluated values
std::cout << "Book: " << this->_code << "\nPrice: $"
<< this->_single_copy_price
<< "\nInventory: " << this->_number_on_hand
<< "\nEnrollment: " << this->_prospective_enrollment
- << "\nRequired: " << (this->_required ? "Yes" : "No")
- << "\nUsed: " << (this->_used ? "Yes" : "No") << std::endl;
+ << "\nRequired: " << (this->_is_required ? "Yes" : "No")
+ << "\nUsed: " << (this->_is_used ? "Yes" : "No") << std::endl;
}
-auto Textbook::evaluate_needs() -> void {
+void Textbook::EvaluateNeeds() {
/// Calculate the total cost of the books to order based on an input factor
const auto set_amount_to_order = [this](double factor) -> void {
this->_amount_to_order =
@@ -57,13 +48,13 @@ auto Textbook::evaluate_needs() -> void {
};
// Determine amount to order based on given percentages
- if (this->_required && !this->_used) {
+ if (this->_is_required && !this->_is_used) {
set_amount_to_order(0.9);
- } else if (this->_required && this->_used) {
+ } else if (this->_is_required && this->_is_used) {
set_amount_to_order(0.65);
- } else if (!this->_required && !this->_used) {
+ } else if (!this->_is_required && !this->_is_used) {
set_amount_to_order(0.4);
- } else if (!this->_required && this->_used) {
+ } else if (!this->_is_required && this->_is_used) {
set_amount_to_order(0.2);
}
@@ -72,17 +63,17 @@ auto Textbook::evaluate_needs() -> void {
static_cast<double>(this->_amount_to_order) * this->_single_copy_price;
}
-auto Textbook::print_needs() const -> void {
+void Textbook::PrintNeeds() const {
// Pretty print the amount to order and total cost
std::cout << "Need to order: " << this->_amount_to_order << "\nTotal cost: $"
<< std::fixed << std::setprecision(2) << this->_total_cost
<< std::endl;
}
-auto Textbook::operator==(const Textbook &other) const -> bool {
+bool Textbook::operator==(const Textbook &other) const {
return this->_code == other._code;
}
-auto Textbook::operator!=(const Textbook &other) const -> bool {
+bool Textbook::operator!=(const Textbook &other) const {
return this->_code != other._code;
}
-} // namespace textbook
+} // namespace Textbook