summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-05-18 00:38:03 -0700
committerFuwn <[email protected]>2024-05-18 00:38:03 -0700
commitb6233bd925eb8bcf848e580371814e3bd745c63f (patch)
tree0ab5728b7153c435ad4dadcb42af9e744f70da9a
parentf (diff)
downloadcst_136_assignment_07-main.tar.xz
cst_136_assignment_07-main.zip
-rw-r--r--.tup/dbbin86016 -> 155648 bytes
-rw-r--r--College.hh14
-rw-r--r--College_Impl.cpp22
-rw-r--r--High_School.hh15
-rw-r--r--High_School_Impl.cpp28
-rw-r--r--School_Driver.cpp45
-rw-r--r--Tupfile4
-rw-r--r--University.hh15
-rw-r--r--build/College_Impl.obin162216 -> 0 bytes
-rw-r--r--build/High_School_Impl.obin162368 -> 0 bytes
-rw-r--r--build/School_Driver.obin103600 -> 0 bytes
-rw-r--r--build/University_Impl.obin142632 -> 0 bytes
-rwxr-xr-xbuild/cst_136_assignment_07bin5478608 -> 0 bytes
13 files changed, 117 insertions, 26 deletions
diff --git a/.tup/db b/.tup/db
index 89e67b1..b673c7e 100644
--- a/.tup/db
+++ b/.tup/db
Binary files differ
diff --git a/College.hh b/College.hh
index 756bffe..8b0b728 100644
--- a/College.hh
+++ b/College.hh
@@ -21,10 +21,20 @@ public:
void set_college_name(std::string);
std::string get_college_name();
+
void set_college_location(std::string);
std::string get_college_location();
- //......other setters and getters
- bool operator==(const University &);
+ void set_college_rank(int);
+ int get_college_rank();
+
+ void set_reqd_gpa_for_admit(double);
+ double get_reqd_gpa_for_admit();
+
+ void set_university_pin(const University &);
+ University get_university_pin();
+
void print_pin();
+
+ bool operator==(const University &) const;
};
diff --git a/College_Impl.cpp b/College_Impl.cpp
index 1d96b2d..4e0b17d 100644
--- a/College_Impl.cpp
+++ b/College_Impl.cpp
@@ -19,7 +19,27 @@ auto College::get_college_location() -> std::string {
return this->college_location;
}
-auto College::operator==(const University &university) -> bool {
+auto College::set_college_rank(int rank) -> void { this->college_rank = rank; }
+
+auto College::get_college_rank() -> int { return this->college_rank; }
+
+auto College::set_reqd_gpa_for_admit(double gpa) -> void {
+ this->reqd_gpa_for_admit = gpa;
+}
+
+auto College::get_reqd_gpa_for_admit() -> double {
+ return this->reqd_gpa_for_admit;
+}
+
+auto College::set_university_pin(const University &university) -> void {
+ this->university_pin = university;
+}
+
+auto College::get_university_pin() -> University {
+ return this->university_pin;
+}
+
+auto College::operator==(const University &university) const -> bool {
return this->university_pin.get_univ_pin() == university.get_univ_pin();
}
diff --git a/High_School.hh b/High_School.hh
index 44950ab..152cf25 100644
--- a/High_School.hh
+++ b/High_School.hh
@@ -24,9 +24,20 @@ public:
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
- bool operator==(const University &);
+
+ void set_high_school_rank(int);
+ int get_high_school_rank();
+
+ void set_reqd_gpa_for_admit(double);
+ double get_reqd_gpa_for_admit();
+
+ void set_university_pin(const University &);
+ University get_university_pin();
+
+ bool operator==(const University &) const;
+
void print_pin();
};
diff --git a/High_School_Impl.cpp b/High_School_Impl.cpp
index 64c410a..11bd770 100644
--- a/High_School_Impl.cpp
+++ b/High_School_Impl.cpp
@@ -21,11 +21,35 @@ auto High_School::get_high_school_location() -> std::string {
return this->high_school_location;
}
-auto High_School::operator==(const University &university) -> bool {
+auto High_School::set_high_school_rank(int rank) -> void {
+ this->high_school_rank = rank;
+}
+
+auto High_School::get_high_school_rank() -> int {
+ return this->high_school_rank;
+}
+
+auto High_School::set_reqd_gpa_for_admit(double gpa) -> void {
+ this->reqd_gpa_for_admit = gpa;
+}
+
+auto High_School::get_reqd_gpa_for_admit() -> double {
+ return this->reqd_gpa_for_admit;
+}
+
+auto High_School::set_university_pin(const University &university) -> void {
+ this->university_pin = university;
+}
+
+auto High_School::get_university_pin() -> University {
+ return this->university_pin;
+}
+
+auto High_School::operator==(const University &university) const -> 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()
+ std::cout << "High School Pin: " << this->university_pin.get_univ_pin()
<< '\n';
}
diff --git a/School_Driver.cpp b/School_Driver.cpp
index 356eee5..98e2004 100644
--- a/School_Driver.cpp
+++ b/School_Driver.cpp
@@ -3,19 +3,46 @@
#include "University.hh"
#include <iostream>
+template <typename L, typename R>
+auto same_university(std::string, const L &, const R &) -> void;
+
auto main() -> int {
University university;
- College college("College of Cool", 1, 3.5);
+
+ university.set_univ_pin(1337);
+
+ College college("College of Cool", "Portland", 1, 3.5, university);
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);
+ college.set_college_name("College of Cool II");
+ college.set_college_location("Los Angeles");
+ college.set_college_rank(7);
+ college.set_reqd_gpa_for_admit(3.99);
+ college.print_pin();
+
+ high_school.set_high_school_name("Cool High School II");
+ high_school.set_high_school_location("New York");
+ high_school.set_high_school_rank(2);
+ high_school.set_reqd_gpa_for_admit(3.2);
+ high_school.print_pin();
+
+ same_university("\ncollege(university) == university", college, university);
+ same_university("high_school == university", high_school, university);
+ same_university("university == university", university, university);
+ same_university("university(anonymous) == university", University(),
+ university);
+
+ high_school.set_university_pin(university);
+
+ same_university("high_school(university) == university", high_school,
+ university);
return 0;
}
+
+template <typename L, typename R>
+auto same_university(std::string description, const L &left, const R &right)
+ -> void {
+ std::cout << description << ": universities are "
+ << (left == right ? "the same" : "different") << ".\n";
+}
diff --git a/Tupfile b/Tupfile
index 70b4a96..21139e2 100644
--- a/Tupfile
+++ b/Tupfile
@@ -3,6 +3,6 @@ CLANG_TIDY_CHECKS='-*,bugprone-*,clang-analyzer-*,concurrency-*,cppcoreguildelin
CC_FLAGS=-std=c++23 -I include -Weverything -Wno-padded -Wno-c++98-compat
CC=zig c++
-: foreach *.cpp |> clang-tidy -checks=$(CLANG_TIDY_CHECKS) %f -- $(CC_FLAGS) |>
-: foreach *.cpp |> ^j^ $(CC) $(CC_FLAGS) -c %f -o %o |> $(BUILD_DIRECTORY)/%B.o
+: foreach *.{cpp,hh} |> clang-format -i %f |>
+: foreach *.cpp |> $(CC) $(CC_FLAGS) -c %f -o %o |> $(BUILD_DIRECTORY)/%B.o
: $(BUILD_DIRECTORY)/*.o |> $(CC) %f -o %o |> $(BUILD_DIRECTORY)/cst_136_assignment_07
diff --git a/University.hh b/University.hh
index 15a28c5..23702a4 100644
--- a/University.hh
+++ b/University.hh
@@ -2,12 +2,9 @@
#include <string>
-// #include "College.hh"
-// #include "High_School.hh"
-
class University {
friend class College;
- friend class high_school;
+ friend class High_School;
private:
std::string university_name;
@@ -15,15 +12,17 @@ private:
static int pin;
public:
- University() = default;
- University(const University &);
+ University() : university_pin(0) {}
+ University(University &) = default;
virtual ~University() = default;
- void set_univ_pin(int upin);
+ void set_univ_pin(int);
int get_univ_pin() const;
+
static void incrementPin() { pin += 1; }
- bool operator==(const University &) const;
virtual void print_univ_pin();
+
+ bool operator==(const University &) const;
};
diff --git a/build/College_Impl.o b/build/College_Impl.o
deleted file mode 100644
index 3a8c4ea..0000000
--- a/build/College_Impl.o
+++ /dev/null
Binary files differ
diff --git a/build/High_School_Impl.o b/build/High_School_Impl.o
deleted file mode 100644
index ac9b263..0000000
--- a/build/High_School_Impl.o
+++ /dev/null
Binary files differ
diff --git a/build/School_Driver.o b/build/School_Driver.o
deleted file mode 100644
index 54baa08..0000000
--- a/build/School_Driver.o
+++ /dev/null
Binary files differ
diff --git a/build/University_Impl.o b/build/University_Impl.o
deleted file mode 100644
index 5167104..0000000
--- a/build/University_Impl.o
+++ /dev/null
Binary files differ
diff --git a/build/cst_136_assignment_07 b/build/cst_136_assignment_07
deleted file mode 100755
index 3605e31..0000000
--- a/build/cst_136_assignment_07
+++ /dev/null
Binary files differ