Class that holds Course information
Dependents: Course_Example course_input class_finder
Course.cpp@6:f231ecc9b944, 2016-12-08 (annotated)
- Committer:
- kkizirian
- Date:
- Thu Dec 08 17:15:04 2016 +0000
- Revision:
- 6:f231ecc9b944
- Parent:
- 5:7d792c9848bb
- Child:
- 7:fe9fcb384036
Using map class to make things easier
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kkizirian | 0:72f706b36195 | 1 | #include "Course.h" |
kkizirian | 5:7d792c9848bb | 2 | //#include <string> |
kkizirian | 0:72f706b36195 | 3 | |
kkizirian | 6:f231ecc9b944 | 4 | map<string, float> create_lat_map() { |
kkizirian | 2:8f163dc0b6c4 | 5 | map<string, float> m; |
kkizirian | 2:8f163dc0b6c4 | 6 | m["CLH"] = 33.774801; |
kkizirian | 2:8f163dc0b6c4 | 7 | m["COC"] = 33.777442; |
kkizirian | 6:f231ecc9b944 | 8 | m["KLS"] = 33.777262; |
kkizirian | 6:f231ecc9b944 | 9 | m["VAN"] = 33.775991; |
kkizirian | 2:8f163dc0b6c4 | 10 | return m; |
kkizirian | 2:8f163dc0b6c4 | 11 | } |
kkizirian | 2:8f163dc0b6c4 | 12 | |
kkizirian | 2:8f163dc0b6c4 | 13 | map<string, float> create_long_map() { |
kkizirian | 2:8f163dc0b6c4 | 14 | map<string, float> m; |
kkizirian | 6:f231ecc9b944 | 15 | m["CLH"] = -84.396389; |
kkizirian | 2:8f163dc0b6c4 | 16 | m["COC"] = -84.397259; |
kkizirian | 6:f231ecc9b944 | 17 | m["KLS"] = -84.396003; |
kkizirian | 6:f231ecc9b944 | 18 | m["VAN"] = -84.397128; |
kkizirian | 2:8f163dc0b6c4 | 19 | return m; |
kkizirian | 2:8f163dc0b6c4 | 20 | } |
kkizirian | 2:8f163dc0b6c4 | 21 | |
kkizirian | 2:8f163dc0b6c4 | 22 | map<string, string> create_names_map() { |
kkizirian | 2:8f163dc0b6c4 | 23 | map<string, string> m; |
kkizirian | 2:8f163dc0b6c4 | 24 | m["CLH"] = "Clough"; |
kkizirian | 3:e2024ec77d96 | 25 | m["COC"] = "CoC"; |
kkizirian | 2:8f163dc0b6c4 | 26 | m["KLS"] = "Klaus"; |
kkizirian | 4:bc4b05dacca3 | 27 | m["VAN"] = "VanLeer"; |
kkizirian | 2:8f163dc0b6c4 | 28 | return m; |
kkizirian | 6:f231ecc9b944 | 29 | } |
kkizirian | 2:8f163dc0b6c4 | 30 | |
kkizirian | 6:f231ecc9b944 | 31 | map<string, float> Course::buildingLAT = create_lat_map(); |
kkizirian | 6:f231ecc9b944 | 32 | map<string, float> Course::buildingLONG = create_long_map(); |
kkizirian | 6:f231ecc9b944 | 33 | map<string, string> Course::buildingNames = create_names_map(); |
kkizirian | 0:72f706b36195 | 34 | |
kkizirian | 0:72f706b36195 | 35 | Course :: Course(string pAbbreviatedName, int pHour, int pMinute, string pAMPM) { |
kkizirian | 5:7d792c9848bb | 36 | |
kkizirian | 6:f231ecc9b944 | 37 | /*if (pAbbreviatedName == "CLH") { |
kkizirian | 5:7d792c9848bb | 38 | fullName = "Clough"; |
kkizirian | 5:7d792c9848bb | 39 | latitude = 33.774801; |
kkizirian | 6:f231ecc9b944 | 40 | longitude = -84.396389; |
kkizirian | 5:7d792c9848bb | 41 | } |
kkizirian | 5:7d792c9848bb | 42 | else if (pAbbreviatedName == "COC") { |
kkizirian | 5:7d792c9848bb | 43 | fullName = "CoC"; |
kkizirian | 5:7d792c9848bb | 44 | latitude = 33.777442; |
kkizirian | 5:7d792c9848bb | 45 | longitude = -84.397259; |
kkizirian | 5:7d792c9848bb | 46 | } |
kkizirian | 5:7d792c9848bb | 47 | else if (pAbbreviatedName == "KLS") { |
kkizirian | 5:7d792c9848bb | 48 | fullName = "Klaus"; |
kkizirian | 6:f231ecc9b944 | 49 | latitude = 33.777262; |
kkizirian | 6:f231ecc9b944 | 50 | longitude = -84.396003; |
kkizirian | 5:7d792c9848bb | 51 | } |
kkizirian | 5:7d792c9848bb | 52 | else if (pAbbreviatedName == "VAN") { |
kkizirian | 5:7d792c9848bb | 53 | fullName = "VanLeer"; |
kkizirian | 5:7d792c9848bb | 54 | latitude = 33.776000; |
kkizirian | 5:7d792c9848bb | 55 | longitude = -84.397132; |
kkizirian | 6:f231ecc9b944 | 56 | }*/ |
kkizirian | 5:7d792c9848bb | 57 | |
kkizirian | 2:8f163dc0b6c4 | 58 | //createBuildingMaps(); |
kkizirian | 0:72f706b36195 | 59 | abbreviatedName = pAbbreviatedName; |
kkizirian | 6:f231ecc9b944 | 60 | fullName = buildingNames[pAbbreviatedName]; |
kkizirian | 6:f231ecc9b944 | 61 | latitude = buildingLAT[pAbbreviatedName]; |
kkizirian | 6:f231ecc9b944 | 62 | longitude = buildingLONG[pAbbreviatedName]; |
kkizirian | 0:72f706b36195 | 63 | ampm = pAMPM; |
kkizirian | 0:72f706b36195 | 64 | hour = pHour; |
kkizirian | 0:72f706b36195 | 65 | minute = pMinute; |
kkizirian | 0:72f706b36195 | 66 | } |
kkizirian | 0:72f706b36195 | 67 | |
kkizirian | 0:72f706b36195 | 68 | string Course :: getAbbreviatedName() { |
kkizirian | 0:72f706b36195 | 69 | return abbreviatedName; |
kkizirian | 0:72f706b36195 | 70 | } |
kkizirian | 0:72f706b36195 | 71 | |
kkizirian | 0:72f706b36195 | 72 | string Course :: getFullName() { |
kkizirian | 0:72f706b36195 | 73 | return fullName; |
kkizirian | 0:72f706b36195 | 74 | } |
kkizirian | 0:72f706b36195 | 75 | |
kkizirian | 0:72f706b36195 | 76 | int Course :: getHour() { |
kkizirian | 0:72f706b36195 | 77 | return hour; |
kkizirian | 0:72f706b36195 | 78 | } |
kkizirian | 0:72f706b36195 | 79 | |
kkizirian | 2:8f163dc0b6c4 | 80 | int Course :: getHour_forCompare() { |
kkizirian | 2:8f163dc0b6c4 | 81 | if (hour == 12) |
kkizirian | 2:8f163dc0b6c4 | 82 | return 0; |
kkizirian | 2:8f163dc0b6c4 | 83 | else |
kkizirian | 3:e2024ec77d96 | 84 | return hour; |
kkizirian | 2:8f163dc0b6c4 | 85 | } |
kkizirian | 2:8f163dc0b6c4 | 86 | |
kkizirian | 5:7d792c9848bb | 87 | string Course :: getMinute_toString() { |
kkizirian | 5:7d792c9848bb | 88 | char minuteBuf[3]; |
kkizirian | 5:7d792c9848bb | 89 | sprintf(minuteBuf, "%i", minute); |
kkizirian | 5:7d792c9848bb | 90 | minuteBuf[2] = '\0'; |
kkizirian | 4:bc4b05dacca3 | 91 | |
kkizirian | 5:7d792c9848bb | 92 | string minuteStr = minuteBuf; |
kkizirian | 4:bc4b05dacca3 | 93 | |
kkizirian | 5:7d792c9848bb | 94 | if (this->getMinute() < 10) |
kkizirian | 5:7d792c9848bb | 95 | minuteStr = "0" + minuteStr; |
kkizirian | 4:bc4b05dacca3 | 96 | |
kkizirian | 5:7d792c9848bb | 97 | return minuteStr; |
kkizirian | 4:bc4b05dacca3 | 98 | } |
kkizirian | 4:bc4b05dacca3 | 99 | |
kkizirian | 0:72f706b36195 | 100 | int Course :: getMinute() { |
kkizirian | 0:72f706b36195 | 101 | return minute; |
kkizirian | 0:72f706b36195 | 102 | } |
kkizirian | 0:72f706b36195 | 103 | |
kkizirian | 0:72f706b36195 | 104 | float Course :: getLat() { |
kkizirian | 0:72f706b36195 | 105 | return latitude; |
kkizirian | 0:72f706b36195 | 106 | } |
kkizirian | 0:72f706b36195 | 107 | |
kkizirian | 0:72f706b36195 | 108 | float Course :: getLong() { |
kkizirian | 0:72f706b36195 | 109 | return longitude; |
kkizirian | 0:72f706b36195 | 110 | } |
kkizirian | 0:72f706b36195 | 111 | |
kkizirian | 0:72f706b36195 | 112 | string Course :: getAMPM() { |
kkizirian | 0:72f706b36195 | 113 | return ampm; |
kkizirian | 0:72f706b36195 | 114 | } |
kkizirian | 0:72f706b36195 | 115 | |
kkizirian | 0:72f706b36195 | 116 | int Course :: getAMPM_toInt() { |
kkizirian | 0:72f706b36195 | 117 | if (ampm == "AM") |
kkizirian | 0:72f706b36195 | 118 | return 0; |
kkizirian | 0:72f706b36195 | 119 | else |
kkizirian | 0:72f706b36195 | 120 | return 1; |
kkizirian | 0:72f706b36195 | 121 | } |
kkizirian | 0:72f706b36195 | 122 | |
kkizirian | 0:72f706b36195 | 123 | string Course :: getFileString() { |
kkizirian | 0:72f706b36195 | 124 | string output = ""; |
kkizirian | 0:72f706b36195 | 125 | char hourBuf[3]; |
kkizirian | 0:72f706b36195 | 126 | char minuteBuf[3]; |
kkizirian | 0:72f706b36195 | 127 | sprintf(hourBuf, "%i", hour); |
kkizirian | 0:72f706b36195 | 128 | sprintf(minuteBuf, "%i", minute); |
kkizirian | 0:72f706b36195 | 129 | |
kkizirian | 0:72f706b36195 | 130 | string hourStr = hourBuf; |
kkizirian | 0:72f706b36195 | 131 | string minuteStr = minuteBuf; |
kkizirian | 1:b02713ff0bd5 | 132 | |
kkizirian | 1:b02713ff0bd5 | 133 | if (this->getHour() < 10) |
kkizirian | 1:b02713ff0bd5 | 134 | hourStr = "0" + hourStr; |
kkizirian | 1:b02713ff0bd5 | 135 | |
kkizirian | 1:b02713ff0bd5 | 136 | if (this->getMinute() < 10) |
kkizirian | 1:b02713ff0bd5 | 137 | minuteStr = "0" + minuteStr; |
kkizirian | 0:72f706b36195 | 138 | |
kkizirian | 0:72f706b36195 | 139 | output = this->getAbbreviatedName() + "," + hourStr + "," + |
kkizirian | 0:72f706b36195 | 140 | minuteStr + "," + this->getAMPM(); |
kkizirian | 0:72f706b36195 | 141 | return output; |
kkizirian | 0:72f706b36195 | 142 | } |
kkizirian | 0:72f706b36195 | 143 | |
kkizirian | 0:72f706b36195 | 144 | string Course :: getDisplayString() { |
kkizirian | 0:72f706b36195 | 145 | string output = ""; |
kkizirian | 0:72f706b36195 | 146 | char hourBuf[3]; |
kkizirian | 0:72f706b36195 | 147 | char minuteBuf[3]; |
kkizirian | 0:72f706b36195 | 148 | sprintf(hourBuf, "%i", hour); |
kkizirian | 0:72f706b36195 | 149 | sprintf(minuteBuf, "%i", minute); |
kkizirian | 0:72f706b36195 | 150 | |
kkizirian | 0:72f706b36195 | 151 | string hourStr = hourBuf; |
kkizirian | 0:72f706b36195 | 152 | string minuteStr = minuteBuf; |
kkizirian | 0:72f706b36195 | 153 | |
kkizirian | 0:72f706b36195 | 154 | if (this->getMinute() < 10) { |
kkizirian | 0:72f706b36195 | 155 | minuteStr = "0" + minuteStr; |
kkizirian | 0:72f706b36195 | 156 | } |
kkizirian | 0:72f706b36195 | 157 | |
kkizirian | 4:bc4b05dacca3 | 158 | output = this->getFullName() + " at " + hourStr + ":" + minuteStr + "" + this->getAMPM(); |
kkizirian | 0:72f706b36195 | 159 | return output; |
kkizirian | 0:72f706b36195 | 160 | } |
kkizirian | 2:8f163dc0b6c4 | 161 | /* |
kkizirian | 0:72f706b36195 | 162 | void Course :: createBuildingMaps() { |
kkizirian | 0:72f706b36195 | 163 | buildingLAT["ALN"] = 33.776078; buildingLONG["ALN"] = -84.398785; |
kkizirian | 0:72f706b36195 | 164 | buildingNames["ALN"] = "Allen"; |
kkizirian | 0:72f706b36195 | 165 | buildingLAT["BUR"] = 33.775660; buildingLONG["BUR"] = -84.398222; |
kkizirian | 0:72f706b36195 | 166 | buildingNames["BUR"] = "Burger-Henry"; |
kkizirian | 0:72f706b36195 | 167 | buildingLAT["CAD"] = 33.776631; buildingLONG["CAD"] = -84.396969; |
kkizirian | 0:72f706b36195 | 168 | buildingNames["CAD"] = "Caddell"; |
kkizirian | 0:72f706b36195 | 169 | buildingLAT["CHR"] = 33.777959; buildingLONG["CHR"] = -84.397051; |
kkizirian | 0:72f706b36195 | 170 | buildingNames["CHR"] = "Cherry"; |
kkizirian | 0:72f706b36195 | 171 | buildingLAT["CLH"] = 33.774801; buildingLONG["CLH"] = -84.396376; |
kkizirian | 0:72f706b36195 | 172 | buildingNames["CLH"] = "Clough"; |
kkizirian | 0:72f706b36195 | 173 | buildingLAT["COC"] = 33.777442; buildingLONG["COC"] = -84.397259; |
kkizirian | 0:72f706b36195 | 174 | buildingNames["COC"] = "College of Computing"; |
kkizirian | 0:72f706b36195 | 175 | buildingLAT["COD"] = 33.776010; buildingLONG["COD"] = -84.395561; |
kkizirian | 0:72f706b36195 | 176 | buildingNames["COD"] = "College of Design"; |
kkizirian | 0:72f706b36195 | 177 | buildingLAT["COO"] = 33.772724; buildingLONG["COO"] = -84.395770; |
kkizirian | 0:72f706b36195 | 178 | buildingNames["COO"] = "Coon Building"; |
kkizirian | 0:72f706b36195 | 179 | buildingLAT["CCH"] = 33.778216; buildingLONG["CCH"] = -84.404506; |
kkizirian | 0:72f706b36195 | 180 | buildingNames["CCH"] = "Couch"; |
kkizirian | 0:72f706b36195 | 181 | buildingLAT["FOR"] = 33.778843; buildingLONG["FOR"] = -84.395849; |
kkizirian | 0:72f706b36195 | 182 | buildingNames["FOR"] = "Ford"; |
kkizirian | 0:72f706b36195 | 183 | buildingLAT["GUG"] = 33.771628; buildingLONG["GUG"] = -84.395775; |
kkizirian | 0:72f706b36195 | 184 | buildingNames["GUG"] = "Guggenheim"; |
kkizirian | 0:72f706b36195 | 185 | buildingLAT["HWY"] = 33.777498; buildingLONG["HWY"] = -84.398582; |
kkizirian | 0:72f706b36195 | 186 | buildingNames["HWY"] = "Howey"; |
kkizirian | 0:72f706b36195 | 187 | buildingLAT["ICR"] = 33.775448; buildingLONG["ICR"] = -84.401261; |
kkizirian | 0:72f706b36195 | 188 | buildingNames["ICR"] = "Instructional Center"; |
kkizirian | 0:72f706b36195 | 189 | buildingLAT["IVN"] = 33.774001; buildingLONG["IVN"] = -84.404259; |
kkizirian | 0:72f706b36195 | 190 | buildingNames["IVN"] = "Ivan Allen"; |
kkizirian | 0:72f706b36195 | 191 | buildingLAT["KLS"] = 33.777244; buildingLONG["KLS"] = -84.396256; |
kkizirian | 0:72f706b36195 | 192 | buildingNames["KLS"] = "Klaus"; |
kkizirian | 0:72f706b36195 | 193 | buildingLAT["LVE"] = 33.776730; buildingLONG["LVE"] = -84.401807; |
kkizirian | 0:72f706b36195 | 194 | buildingNames["LVE"] = "Love"; |
kkizirian | 0:72f706b36195 | 195 | buildingLAT["MCS"] = 33.779068; buildingLONG["MCS"] = -84.398651; |
kkizirian | 0:72f706b36195 | 196 | buildingNames["MCS"] = "Marcus Nanotech"; |
kkizirian | 0:72f706b36195 | 197 | buildingLAT["MSN"] = 33.776685; buildingLONG["MSN"] = -84.398896; |
kkizirian | 0:72f706b36195 | 198 | buildingNames["MSN"] = "Mason"; |
kkizirian | 0:72f706b36195 | 199 | buildingLAT["PET"] = 33.778946; buildingLONG["PET"] = -84.397158; |
kkizirian | 0:72f706b36195 | 200 | buildingNames["PET"] = "Petit"; |
kkizirian | 0:72f706b36195 | 201 | buildingLAT["SCH"] = 33.776562; buildingLONG["SCH"] = -84.388060; |
kkizirian | 0:72f706b36195 | 202 | buildingNames["SCH"] = "Scheller"; |
kkizirian | 0:72f706b36195 | 203 | buildingLAT["SKI"] = 33.773603; buildingLONG["SKI"] = -84.395897; |
kkizirian | 0:72f706b36195 | 204 | buildingNames["SKI"] = "Skiles"; |
kkizirian | 0:72f706b36195 | 205 | buildingLAT["VAN"] = 33.776000; buildingLONG["VAN"] = -84.397132; |
kkizirian | 0:72f706b36195 | 206 | buildingNames["VAN"] = "Van Leer"; |
kkizirian | 2:8f163dc0b6c4 | 207 | }*/ |