diff options
| -rw-r--r-- | .tup/db | bin | 86016 -> 86016 bytes | |||
| -rw-r--r-- | College.hh | 4 | ||||
| -rw-r--r-- | College_Impl.cpp | 10 | ||||
| -rw-r--r-- | High_School.hh | 20 | ||||
| -rw-r--r-- | High_School_Impl.cpp | 31 | ||||
| -rw-r--r-- | School_Driver.cpp | 14 | ||||
| -rw-r--r-- | University.hh | 13 | ||||
| -rw-r--r-- | University_Impl.cpp | 6 | ||||
| -rw-r--r-- | build/College_Impl.o | bin | 161648 -> 162216 bytes | |||
| -rw-r--r-- | build/High_School_Impl.o | bin | 1008 -> 162368 bytes | |||
| -rw-r--r-- | build/School_Driver.o | bin | 28360 -> 103600 bytes | |||
| -rw-r--r-- | build/University_Impl.o | bin | 142952 -> 142632 bytes | |||
| -rwxr-xr-x | build/cst_136_assignment_07 | bin | 5422808 -> 5478608 bytes |
13 files changed, 78 insertions, 20 deletions
| Binary files differ @@ -25,6 +25,6 @@ public: std::string get_college_location(); //......other setters and getters - // void operator==(const University&); - void print_pin(const University &); + bool operator==(const University &); + void print_pin(); }; diff --git a/College_Impl.cpp b/College_Impl.cpp index 6f9c66c..1d96b2d 100644 --- a/College_Impl.cpp +++ b/College_Impl.cpp @@ -19,11 +19,11 @@ auto College::get_college_location() -> std::string { return this->college_location; } -// auto College::operator==(University) -> void { -// // compare all fields of college and university -// } +auto College::operator==(const University &university) -> bool { + return this->university_pin.get_univ_pin() == university.get_univ_pin(); +} -auto College::print_pin(const University &) -> void { - std::cout << "University pin: " << this->university_pin.get_univ_pin() +auto College::print_pin() -> void { + std::cout << "University Pin: " << this->university_pin.get_univ_pin() << '\n'; } diff --git a/High_School.hh b/High_School.hh index 8501456..44950ab 100644 --- a/High_School.hh +++ b/High_School.hh @@ -1,8 +1,10 @@ #pragma once +#include <string> + #include "University.hh" -class high_school { +class High_School { private: std::string high_school_name; std::string high_school_location; @@ -11,14 +13,20 @@ private: University university_pin; public: - high_school() {} - high_school(std::string, int, double); - high_school(std::string, std::string, int, double, University); + High_School() {} + High_School(std::string name, int rank, double gpa) + : high_school_name(name), high_school_rank(rank), + reqd_gpa_for_admit(gpa) {} + High_School(std::string name, std::string location, int rank, double gpa, + University pin) + : high_school_name(name), high_school_location(location), + high_school_rank(rank), reqd_gpa_for_admit(gpa), university_pin(pin) {} + void set_high_school_name(std::string); std::string get_high_school_name(); void set_high_school_location(std::string); std::string get_high_school_location(); //......other setters and getters - void operator==(University); - void print_pin(University); + bool operator==(const University &); + void print_pin(); }; diff --git a/High_School_Impl.cpp b/High_School_Impl.cpp index e69de29..64c410a 100644 --- a/High_School_Impl.cpp +++ b/High_School_Impl.cpp @@ -0,0 +1,31 @@ +#include <iostream> +#include <string> +#include <utility> + +#include "High_School.hh" +#include "University.hh" + +auto High_School::set_high_school_name(std::string name) -> void { + this->high_school_name = std::move(name); +} + +auto High_School::get_high_school_name() -> std::string { + return this->high_school_name; +} + +auto High_School::set_high_school_location(std::string location) -> void { + this->high_school_location = std::move(location); +} + +auto High_School::get_high_school_location() -> std::string { + return this->high_school_location; +} + +auto High_School::operator==(const University &university) -> bool { + return this->university_pin.get_univ_pin() == university.get_univ_pin(); +} + +auto High_School::print_pin() -> void { + std::cout << "University Pin: " << this->university_pin.get_univ_pin() + << '\n'; +} diff --git a/School_Driver.cpp b/School_Driver.cpp index 93532ca..356eee5 100644 --- a/School_Driver.cpp +++ b/School_Driver.cpp @@ -1,9 +1,21 @@ #include "College.hh" #include "High_School.hh" #include "University.hh" +#include <iostream> auto main() -> int { - // + University university; + College college("College of Cool", 1, 3.5); + High_School high_school("Cool High School", 2, 3.7); + auto same_college = [](University &college, University &university) { + if (college == university) { + std::cout << "Same college\n"; + } else { + std::cout << "Different college\n"; + } + }; + + same_college(college, university); return 0; } diff --git a/University.hh b/University.hh index 16f86be..15a28c5 100644 --- a/University.hh +++ b/University.hh @@ -2,8 +2,13 @@ #include <string> +// #include "College.hh" +// #include "High_School.hh" + class University { - // declare friend classes college and high_school here + friend class College; + friend class high_school; + private: std::string university_name; int university_pin; @@ -16,11 +21,9 @@ public: virtual ~University() = default; void set_univ_pin(int upin); - int get_univ_pin(); + int get_univ_pin() const; static void incrementPin() { pin += 1; } - // == typical returns a boolean, and since this is under the getters section, - // I'll take it that this was meant to be for assignment. - University &operator=(const University &) = default; + bool operator==(const University &) const; virtual void print_univ_pin(); }; diff --git a/University_Impl.cpp b/University_Impl.cpp index c36d709..8cd76a8 100644 --- a/University_Impl.cpp +++ b/University_Impl.cpp @@ -4,7 +4,11 @@ auto University::set_univ_pin(int upin) -> void { this->university_pin = upin; } -auto University::get_univ_pin() -> int { return this->university_pin; } +auto University::get_univ_pin() const -> int { return this->university_pin; } + +auto University::operator==(const University &university) const -> bool { + return this->university_pin == university.get_univ_pin(); +} auto University::print_univ_pin() -> void { std::cout << "University pin: " << this->university_pin << '\n'; diff --git a/build/College_Impl.o b/build/College_Impl.o Binary files differindex a1afef7..3a8c4ea 100644 --- a/build/College_Impl.o +++ b/build/College_Impl.o diff --git a/build/High_School_Impl.o b/build/High_School_Impl.o Binary files differindex 27fadb0..ac9b263 100644 --- a/build/High_School_Impl.o +++ b/build/High_School_Impl.o diff --git a/build/School_Driver.o b/build/School_Driver.o Binary files differindex c9789e5..54baa08 100644 --- a/build/School_Driver.o +++ b/build/School_Driver.o diff --git a/build/University_Impl.o b/build/University_Impl.o Binary files differindex f968af4..5167104 100644 --- a/build/University_Impl.o +++ b/build/University_Impl.o diff --git a/build/cst_136_assignment_07 b/build/cst_136_assignment_07 Binary files differindex 9c3d455..3605e31 100755 --- a/build/cst_136_assignment_07 +++ b/build/cst_136_assignment_07 |