Class that holds Course information
Dependents: Course_Example course_input class_finder
Course.cpp@7:fe9fcb384036, 2016-12-08 (annotated)
- Committer:
- kkizirian
- Date:
- Thu Dec 08 17:59:37 2016 +0000
- Revision:
- 7:fe9fcb384036
- Parent:
- 6:f231ecc9b944
- Child:
- 8:f235174016c8
Added getHour_inMilitaryTime() to get hour in 24 hour clock, to be compared with GPS time
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 | 7:fe9fcb384036 | 87 | int Course :: getHour_inMilitaryTime() { |
kkizirian | 7:fe9fcb384036 | 88 | if (this->getAMPM() == "PM") |
kkizirian | 7:fe9fcb384036 | 89 | return hour + 12; |
kkizirian | 7:fe9fcb384036 | 90 | else |
kkizirian | 7:fe9fcb384036 | 91 | return hour; |
kkizirian | 7:fe9fcb384036 | 92 | |
kkizirian | 7:fe9fcb384036 | 93 | } |
kkizirian | 7:fe9fcb384036 | 94 | |
kkizirian | 5:7d792c9848bb | 95 | string Course :: getMinute_toString() { |
kkizirian | 5:7d792c9848bb | 96 | char minuteBuf[3]; |
kkizirian | 5:7d792c9848bb | 97 | sprintf(minuteBuf, "%i", minute); |
kkizirian | 5:7d792c9848bb | 98 | minuteBuf[2] = '\0'; |
kkizirian | 4:bc4b05dacca3 | 99 | |
kkizirian | 5:7d792c9848bb | 100 | string minuteStr = minuteBuf; |
kkizirian | 4:bc4b05dacca3 | 101 | |
kkizirian | 5:7d792c9848bb | 102 | if (this->getMinute() < 10) |
kkizirian | 5:7d792c9848bb | 103 | minuteStr = "0" + minuteStr; |
kkizirian | 4:bc4b05dacca3 | 104 | |
kkizirian | 5:7d792c9848bb | 105 | return minuteStr; |
kkizirian | 4:bc4b05dacca3 | 106 | } |
kkizirian | 4:bc4b05dacca3 | 107 | |
kkizirian | 0:72f706b36195 | 108 | int Course :: getMinute() { |
kkizirian | 0:72f706b36195 | 109 | return minute; |
kkizirian | 0:72f706b36195 | 110 | } |
kkizirian | 0:72f706b36195 | 111 | |
kkizirian | 0:72f706b36195 | 112 | float Course :: getLat() { |
kkizirian | 0:72f706b36195 | 113 | return latitude; |
kkizirian | 0:72f706b36195 | 114 | } |
kkizirian | 0:72f706b36195 | 115 | |
kkizirian | 0:72f706b36195 | 116 | float Course :: getLong() { |
kkizirian | 0:72f706b36195 | 117 | return longitude; |
kkizirian | 0:72f706b36195 | 118 | } |
kkizirian | 0:72f706b36195 | 119 | |
kkizirian | 0:72f706b36195 | 120 | string Course :: getAMPM() { |
kkizirian | 0:72f706b36195 | 121 | return ampm; |
kkizirian | 0:72f706b36195 | 122 | } |
kkizirian | 0:72f706b36195 | 123 | |
kkizirian | 0:72f706b36195 | 124 | int Course :: getAMPM_toInt() { |
kkizirian | 0:72f706b36195 | 125 | if (ampm == "AM") |
kkizirian | 0:72f706b36195 | 126 | return 0; |
kkizirian | 0:72f706b36195 | 127 | else |
kkizirian | 0:72f706b36195 | 128 | return 1; |
kkizirian | 0:72f706b36195 | 129 | } |
kkizirian | 0:72f706b36195 | 130 | |
kkizirian | 0:72f706b36195 | 131 | string Course :: getFileString() { |
kkizirian | 0:72f706b36195 | 132 | string output = ""; |
kkizirian | 0:72f706b36195 | 133 | char hourBuf[3]; |
kkizirian | 0:72f706b36195 | 134 | char minuteBuf[3]; |
kkizirian | 0:72f706b36195 | 135 | sprintf(hourBuf, "%i", hour); |
kkizirian | 0:72f706b36195 | 136 | sprintf(minuteBuf, "%i", minute); |
kkizirian | 0:72f706b36195 | 137 | |
kkizirian | 0:72f706b36195 | 138 | string hourStr = hourBuf; |
kkizirian | 0:72f706b36195 | 139 | string minuteStr = minuteBuf; |
kkizirian | 1:b02713ff0bd5 | 140 | |
kkizirian | 1:b02713ff0bd5 | 141 | if (this->getHour() < 10) |
kkizirian | 1:b02713ff0bd5 | 142 | hourStr = "0" + hourStr; |
kkizirian | 1:b02713ff0bd5 | 143 | |
kkizirian | 1:b02713ff0bd5 | 144 | if (this->getMinute() < 10) |
kkizirian | 1:b02713ff0bd5 | 145 | minuteStr = "0" + minuteStr; |
kkizirian | 0:72f706b36195 | 146 | |
kkizirian | 0:72f706b36195 | 147 | output = this->getAbbreviatedName() + "," + hourStr + "," + |
kkizirian | 0:72f706b36195 | 148 | minuteStr + "," + this->getAMPM(); |
kkizirian | 0:72f706b36195 | 149 | return output; |
kkizirian | 0:72f706b36195 | 150 | } |
kkizirian | 0:72f706b36195 | 151 | |
kkizirian | 0:72f706b36195 | 152 | string Course :: getDisplayString() { |
kkizirian | 0:72f706b36195 | 153 | string output = ""; |
kkizirian | 0:72f706b36195 | 154 | char hourBuf[3]; |
kkizirian | 0:72f706b36195 | 155 | char minuteBuf[3]; |
kkizirian | 0:72f706b36195 | 156 | sprintf(hourBuf, "%i", hour); |
kkizirian | 0:72f706b36195 | 157 | sprintf(minuteBuf, "%i", minute); |
kkizirian | 0:72f706b36195 | 158 | |
kkizirian | 0:72f706b36195 | 159 | string hourStr = hourBuf; |
kkizirian | 0:72f706b36195 | 160 | string minuteStr = minuteBuf; |
kkizirian | 0:72f706b36195 | 161 | |
kkizirian | 0:72f706b36195 | 162 | if (this->getMinute() < 10) { |
kkizirian | 0:72f706b36195 | 163 | minuteStr = "0" + minuteStr; |
kkizirian | 0:72f706b36195 | 164 | } |
kkizirian | 0:72f706b36195 | 165 | |
kkizirian | 4:bc4b05dacca3 | 166 | output = this->getFullName() + " at " + hourStr + ":" + minuteStr + "" + this->getAMPM(); |
kkizirian | 0:72f706b36195 | 167 | return output; |
kkizirian | 0:72f706b36195 | 168 | } |
kkizirian | 2:8f163dc0b6c4 | 169 | /* |
kkizirian | 0:72f706b36195 | 170 | void Course :: createBuildingMaps() { |
kkizirian | 0:72f706b36195 | 171 | buildingLAT["ALN"] = 33.776078; buildingLONG["ALN"] = -84.398785; |
kkizirian | 0:72f706b36195 | 172 | buildingNames["ALN"] = "Allen"; |
kkizirian | 0:72f706b36195 | 173 | buildingLAT["BUR"] = 33.775660; buildingLONG["BUR"] = -84.398222; |
kkizirian | 0:72f706b36195 | 174 | buildingNames["BUR"] = "Burger-Henry"; |
kkizirian | 0:72f706b36195 | 175 | buildingLAT["CAD"] = 33.776631; buildingLONG["CAD"] = -84.396969; |
kkizirian | 0:72f706b36195 | 176 | buildingNames["CAD"] = "Caddell"; |
kkizirian | 0:72f706b36195 | 177 | buildingLAT["CHR"] = 33.777959; buildingLONG["CHR"] = -84.397051; |
kkizirian | 0:72f706b36195 | 178 | buildingNames["CHR"] = "Cherry"; |
kkizirian | 0:72f706b36195 | 179 | buildingLAT["CLH"] = 33.774801; buildingLONG["CLH"] = -84.396376; |
kkizirian | 0:72f706b36195 | 180 | buildingNames["CLH"] = "Clough"; |
kkizirian | 0:72f706b36195 | 181 | buildingLAT["COC"] = 33.777442; buildingLONG["COC"] = -84.397259; |
kkizirian | 0:72f706b36195 | 182 | buildingNames["COC"] = "College of Computing"; |
kkizirian | 0:72f706b36195 | 183 | buildingLAT["COD"] = 33.776010; buildingLONG["COD"] = -84.395561; |
kkizirian | 0:72f706b36195 | 184 | buildingNames["COD"] = "College of Design"; |
kkizirian | 0:72f706b36195 | 185 | buildingLAT["COO"] = 33.772724; buildingLONG["COO"] = -84.395770; |
kkizirian | 0:72f706b36195 | 186 | buildingNames["COO"] = "Coon Building"; |
kkizirian | 0:72f706b36195 | 187 | buildingLAT["CCH"] = 33.778216; buildingLONG["CCH"] = -84.404506; |
kkizirian | 0:72f706b36195 | 188 | buildingNames["CCH"] = "Couch"; |
kkizirian | 0:72f706b36195 | 189 | buildingLAT["FOR"] = 33.778843; buildingLONG["FOR"] = -84.395849; |
kkizirian | 0:72f706b36195 | 190 | buildingNames["FOR"] = "Ford"; |
kkizirian | 0:72f706b36195 | 191 | buildingLAT["GUG"] = 33.771628; buildingLONG["GUG"] = -84.395775; |
kkizirian | 0:72f706b36195 | 192 | buildingNames["GUG"] = "Guggenheim"; |
kkizirian | 0:72f706b36195 | 193 | buildingLAT["HWY"] = 33.777498; buildingLONG["HWY"] = -84.398582; |
kkizirian | 0:72f706b36195 | 194 | buildingNames["HWY"] = "Howey"; |
kkizirian | 0:72f706b36195 | 195 | buildingLAT["ICR"] = 33.775448; buildingLONG["ICR"] = -84.401261; |
kkizirian | 0:72f706b36195 | 196 | buildingNames["ICR"] = "Instructional Center"; |
kkizirian | 0:72f706b36195 | 197 | buildingLAT["IVN"] = 33.774001; buildingLONG["IVN"] = -84.404259; |
kkizirian | 0:72f706b36195 | 198 | buildingNames["IVN"] = "Ivan Allen"; |
kkizirian | 0:72f706b36195 | 199 | buildingLAT["KLS"] = 33.777244; buildingLONG["KLS"] = -84.396256; |
kkizirian | 0:72f706b36195 | 200 | buildingNames["KLS"] = "Klaus"; |
kkizirian | 0:72f706b36195 | 201 | buildingLAT["LVE"] = 33.776730; buildingLONG["LVE"] = -84.401807; |
kkizirian | 0:72f706b36195 | 202 | buildingNames["LVE"] = "Love"; |
kkizirian | 0:72f706b36195 | 203 | buildingLAT["MCS"] = 33.779068; buildingLONG["MCS"] = -84.398651; |
kkizirian | 0:72f706b36195 | 204 | buildingNames["MCS"] = "Marcus Nanotech"; |
kkizirian | 0:72f706b36195 | 205 | buildingLAT["MSN"] = 33.776685; buildingLONG["MSN"] = -84.398896; |
kkizirian | 0:72f706b36195 | 206 | buildingNames["MSN"] = "Mason"; |
kkizirian | 0:72f706b36195 | 207 | buildingLAT["PET"] = 33.778946; buildingLONG["PET"] = -84.397158; |
kkizirian | 0:72f706b36195 | 208 | buildingNames["PET"] = "Petit"; |
kkizirian | 0:72f706b36195 | 209 | buildingLAT["SCH"] = 33.776562; buildingLONG["SCH"] = -84.388060; |
kkizirian | 0:72f706b36195 | 210 | buildingNames["SCH"] = "Scheller"; |
kkizirian | 0:72f706b36195 | 211 | buildingLAT["SKI"] = 33.773603; buildingLONG["SKI"] = -84.395897; |
kkizirian | 0:72f706b36195 | 212 | buildingNames["SKI"] = "Skiles"; |
kkizirian | 0:72f706b36195 | 213 | buildingLAT["VAN"] = 33.776000; buildingLONG["VAN"] = -84.397132; |
kkizirian | 0:72f706b36195 | 214 | buildingNames["VAN"] = "Van Leer"; |
kkizirian | 2:8f163dc0b6c4 | 215 | }*/ |