From 2b2e14efe75d23e859f4465e4a03efba997a122e Mon Sep 17 00:00:00 2001 From: RainCoder Date: Sun, 29 Jan 2017 18:45:16 -0500 Subject: [PATCH 1/9] Added header file --- Classroom.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Classroom.h diff --git a/Classroom.h b/Classroom.h new file mode 100644 index 0000000..3bcbc3a --- /dev/null +++ b/Classroom.h @@ -0,0 +1,16 @@ +#include +#include + +class Classroom{ +public: + Classroom(); + void setSeats(int x); + int getSeats(); + void setLocation(std::string y); + std::string getLocation(); + +private: + int seats; + std::string location; + +}; From 079115fc705f4f05dd58ba34645a04bc0d09ad6b Mon Sep 17 00:00:00 2001 From: RainCoder Date: Sun, 29 Jan 2017 18:46:33 -0500 Subject: [PATCH 2/9] Added Implementation file --- Classroom.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Classroom.cpp diff --git a/Classroom.cpp b/Classroom.cpp new file mode 100644 index 0000000..9ff293c --- /dev/null +++ b/Classroom.cpp @@ -0,0 +1,25 @@ +#include +#include +#include "Classroom.h" +using namespace std; + +Classroom::Classroom(){ + seats = 0; + location = ""; +} + +void Classroom::setSeats(int x){ + seats = x; +} + +int Classroom::getSeats(){ + return seats; +} + +void Classroom::setLocation(string y){ + location = y; +} + +string Classroom::getLocation(){ + return location; +} From 6eb143c322229e1d80797a17e310461d9ccea723 Mon Sep 17 00:00:00 2001 From: RainCoder Date: Sun, 29 Jan 2017 18:47:03 -0500 Subject: [PATCH 3/9] Added Driver file --- Room.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Room.cpp diff --git a/Room.cpp b/Room.cpp new file mode 100644 index 0000000..63d6019 --- /dev/null +++ b/Room.cpp @@ -0,0 +1,37 @@ +#include +#include +#include +#include "Classroom" +using namespace std; + +int main(){ + + vector room; + int seats = 0; + string location = ""; + + room.push_back(Room1); + room.push_back(Room2); + room.push_back(Room3); + room.push_back(Room4); + + for(int i = 0; i > room.size(); i++){ + cout << "Please enter information about " << room[i] << "\n"; + cout << "How much seats are in the room?"; + cin >> seats; + room[i].setSeats(seats); + cout << "Where is the room located?"; + cin >> location; + room[i].setLocation("location"); + cout << "\n"; + } + + for(int i = 0; i > room.size(); i++){ + cout << "Information about room " << room[i] << "\n"; + cout << "Number of seats: " << room[i].getSeats(); + cout << "Location: " << room[i].getLocation(); + cout << "\n"; + } + system("pause"); + return 0; +} From b7dd436434ea0685cd0817e49daf29e7bfab1544 Mon Sep 17 00:00:00 2001 From: RainCoder Date: Sun, 29 Jan 2017 18:52:18 -0500 Subject: [PATCH 4/9] Corrected error in Room.cpp --- Room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Room.cpp b/Room.cpp index 63d6019..79ebb3d 100644 --- a/Room.cpp +++ b/Room.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "Classroom" +#include "Classroom.h" using namespace std; int main(){ From 3df1c157eb3d7ffbf6756dc67eba21eca1039229 Mon Sep 17 00:00:00 2001 From: RainCoder Date: Sun, 29 Jan 2017 19:16:20 -0500 Subject: [PATCH 5/9] Change include preprocessor --- Classroom.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classroom.h b/Classroom.h index 3bcbc3a..a3f16fc 100644 --- a/Classroom.h +++ b/Classroom.h @@ -1,5 +1,5 @@ -#include -#include +# include +# include class Classroom{ public: From b8ccea0575755d941a5cee66ea84757b956d15cf Mon Sep 17 00:00:00 2001 From: RainCoder Date: Sun, 29 Jan 2017 19:17:33 -0500 Subject: [PATCH 6/9] Changed include preprocessors --- Classroom.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Classroom.cpp b/Classroom.cpp index 9ff293c..bffa8ea 100644 --- a/Classroom.cpp +++ b/Classroom.cpp @@ -1,6 +1,6 @@ -#include -#include -#include "Classroom.h" +# include +# include +# include "Classroom.h" using namespace std; Classroom::Classroom(){ From 0fc11917e6c8eb4d6ba432c9607588a70a1cbdc2 Mon Sep 17 00:00:00 2001 From: RainCoder Date: Sun, 29 Jan 2017 19:18:02 -0500 Subject: [PATCH 7/9] Changed include preprocessors --- Room.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Room.cpp b/Room.cpp index 79ebb3d..4190dcd 100644 --- a/Room.cpp +++ b/Room.cpp @@ -1,14 +1,14 @@ -#include -#include -#include -#include "Classroom.h" +# include +# include +# include +# include "Classroom.h" using namespace std; int main(){ vector room; - int seats = 0; - string location = ""; + int s = 0; + string l = ""; room.push_back(Room1); room.push_back(Room2); @@ -18,11 +18,11 @@ int main(){ for(int i = 0; i > room.size(); i++){ cout << "Please enter information about " << room[i] << "\n"; cout << "How much seats are in the room?"; - cin >> seats; - room[i].setSeats(seats); + cin >> s; + room[i].setSeats(s); cout << "Where is the room located?"; - cin >> location; - room[i].setLocation("location"); + cin >> l; + room[i].setLocation("l"); cout << "\n"; } From 2822192c3254026edc5e5d990c50cff360968990 Mon Sep 17 00:00:00 2001 From: RainCoder Date: Sun, 29 Jan 2017 19:21:31 -0500 Subject: [PATCH 8/9] Added using namespace std; --- Classroom.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Classroom.h b/Classroom.h index a3f16fc..399e5e0 100644 --- a/Classroom.h +++ b/Classroom.h @@ -1,16 +1,17 @@ # include # include +using namespace std; class Classroom{ public: Classroom(); void setSeats(int x); int getSeats(); - void setLocation(std::string y); - std::string getLocation(); + void setLocation(string y); + string getLocation(); private: int seats; - std::string location; + string location; }; From f4d3fb150ab25efa6d686eaf57e6fbbe43464f2a Mon Sep 17 00:00:00 2001 From: RainCoder Date: Mon, 30 Jan 2017 21:01:06 -0500 Subject: [PATCH 9/9] Added parameter to constructor --- Classroom.cpp | 22 +++++++++++----------- Classroom.h | 16 ++++++++-------- Room.cpp | 41 ++++++++++++++--------------------------- 3 files changed, 33 insertions(+), 46 deletions(-) diff --git a/Classroom.cpp b/Classroom.cpp index bffa8ea..8fbbb8a 100644 --- a/Classroom.cpp +++ b/Classroom.cpp @@ -3,23 +3,23 @@ # include "Classroom.h" using namespace std; -Classroom::Classroom(){ - seats = 0; - location = ""; +Classroom::Classroom(int x, string y) { + seats = x; + location = y; } -void Classroom::setSeats(int x){ - seats = x; +void Classroom::setSeats(int x) { + seats = x; } -int Classroom::getSeats(){ - return seats; +int Classroom::getSeats() { + return seats; } -void Classroom::setLocation(string y){ - location = y; +void Classroom::setLocation(string y) { + location = y; } -string Classroom::getLocation(){ - return location; +string Classroom::getLocation() { + return location; } diff --git a/Classroom.h b/Classroom.h index 399e5e0..9057576 100644 --- a/Classroom.h +++ b/Classroom.h @@ -2,16 +2,16 @@ # include using namespace std; -class Classroom{ +class Classroom { public: - Classroom(); - void setSeats(int x); - int getSeats(); - void setLocation(string y); - string getLocation(); + Classroom(int x, string y); + void setSeats(int x); + int getSeats(); + void setLocation(string y); + string getLocation(); private: - int seats; - string location; + int seats; + string location; }; diff --git a/Room.cpp b/Room.cpp index 4190dcd..18c9c8f 100644 --- a/Room.cpp +++ b/Room.cpp @@ -4,34 +4,21 @@ # include "Classroom.h" using namespace std; -int main(){ +int main() { - vector room; - int s = 0; - string l = ""; + vector room; - room.push_back(Room1); - room.push_back(Room2); - room.push_back(Room3); - room.push_back(Room4); + room.push_back({50 , "Lesile Robinson Building"}); + room.push_back({ 40, "Roy Marshall Teaching Complex" }); + room.push_back({ 45, "Roy Marshall Teaching Complex" }); + room.push_back({ 60, "Clico Building" }); - for(int i = 0; i > room.size(); i++){ - cout << "Please enter information about " << room[i] << "\n"; - cout << "How much seats are in the room?"; - cin >> s; - room[i].setSeats(s); - cout << "Where is the room located?"; - cin >> l; - room[i].setLocation("l"); - cout << "\n"; - } - - for(int i = 0; i > room.size(); i++){ - cout << "Information about room " << room[i] << "\n"; - cout << "Number of seats: " << room[i].getSeats(); - cout << "Location: " << room[i].getLocation(); - cout << "\n"; - } - system("pause"); - return 0; + for (unsigned int i = 0; i < room.size(); i++) { + cout << "Information about Room " << i + 1 << "\n"; + cout << "Number of seats: " << room[i].getSeats() << "\n"; + cout << "Location: " << room[i].getLocation(); + cout << "\n"; + } + system("pause"); + return 0; }