Class that holds Course information
Dependents: Course_Example course_input class_finder
Course.cpp@1:b02713ff0bd5, 2016-12-05 (annotated)
- Committer:
- kkizirian
- Date:
- Mon Dec 05 02:47:38 2016 +0000
- Revision:
- 1:b02713ff0bd5
- Parent:
- 0:72f706b36195
- Child:
- 2:8f163dc0b6c4
Fixed the way the file string is handled so that both hour and minute have a leading zero if they are a single digit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kkizirian | 0:72f706b36195 | 1 | #include "Course.h" |
kkizirian | 0:72f706b36195 | 2 | #include <string> |
kkizirian | 0:72f706b36195 | 3 | |
kkizirian | 0:72f706b36195 | 4 | map<string, float> Course::buildingLAT; |
kkizirian | 0:72f706b36195 | 5 | map<string, float> Course::buildingLONG; |
kkizirian | 0:72f706b36195 | 6 | map<string, string> Course::buildingNames; |
kkizirian | 0:72f706b36195 | 7 | |
kkizirian | 0:72f706b36195 | 8 | Course :: Course(string pAbbreviatedName, int pHour, int pMinute, string pAMPM) { |
kkizirian | 0:72f706b36195 | 9 | createBuildingMaps(); |
kkizirian | 0:72f706b36195 | 10 | abbreviatedName = pAbbreviatedName; |
kkizirian | 0:72f706b36195 | 11 | fullName = buildingNames[pAbbreviatedName]; |
kkizirian | 0:72f706b36195 | 12 | latitude = buildingLAT[pAbbreviatedName]; |
kkizirian | 0:72f706b36195 | 13 | longitude = buildingLONG[pAbbreviatedName]; |
kkizirian | 0:72f706b36195 | 14 | ampm = pAMPM; |
kkizirian | 0:72f706b36195 | 15 | hour = pHour; |
kkizirian | 0:72f706b36195 | 16 | minute = pMinute; |
kkizirian | 0:72f706b36195 | 17 | } |
kkizirian | 0:72f706b36195 | 18 | |
kkizirian | 0:72f706b36195 | 19 | string Course :: getAbbreviatedName() { |
kkizirian | 0:72f706b36195 | 20 | return abbreviatedName; |
kkizirian | 0:72f706b36195 | 21 | } |
kkizirian | 0:72f706b36195 | 22 | |
kkizirian | 0:72f706b36195 | 23 | string Course :: getFullName() { |
kkizirian | 0:72f706b36195 | 24 | return fullName; |
kkizirian | 0:72f706b36195 | 25 | } |
kkizirian | 0:72f706b36195 | 26 | |
kkizirian | 0:72f706b36195 | 27 | int Course :: getHour() { |
kkizirian | 0:72f706b36195 | 28 | return hour; |
kkizirian | 0:72f706b36195 | 29 | } |
kkizirian | 0:72f706b36195 | 30 | |
kkizirian | 0:72f706b36195 | 31 | int Course :: getMinute() { |
kkizirian | 0:72f706b36195 | 32 | return minute; |
kkizirian | 0:72f706b36195 | 33 | } |
kkizirian | 0:72f706b36195 | 34 | |
kkizirian | 0:72f706b36195 | 35 | float Course :: getLat() { |
kkizirian | 0:72f706b36195 | 36 | return latitude; |
kkizirian | 0:72f706b36195 | 37 | } |
kkizirian | 0:72f706b36195 | 38 | |
kkizirian | 0:72f706b36195 | 39 | float Course :: getLong() { |
kkizirian | 0:72f706b36195 | 40 | return longitude; |
kkizirian | 0:72f706b36195 | 41 | } |
kkizirian | 0:72f706b36195 | 42 | |
kkizirian | 0:72f706b36195 | 43 | string Course :: getAMPM() { |
kkizirian | 0:72f706b36195 | 44 | return ampm; |
kkizirian | 0:72f706b36195 | 45 | } |
kkizirian | 0:72f706b36195 | 46 | |
kkizirian | 0:72f706b36195 | 47 | int Course :: getAMPM_toInt() { |
kkizirian | 0:72f706b36195 | 48 | if (ampm == "AM") |
kkizirian | 0:72f706b36195 | 49 | return 0; |
kkizirian | 0:72f706b36195 | 50 | else |
kkizirian | 0:72f706b36195 | 51 | return 1; |
kkizirian | 0:72f706b36195 | 52 | } |
kkizirian | 0:72f706b36195 | 53 | |
kkizirian | 0:72f706b36195 | 54 | string Course :: getFileString() { |
kkizirian | 0:72f706b36195 | 55 | string output = ""; |
kkizirian | 0:72f706b36195 | 56 | char hourBuf[3]; |
kkizirian | 0:72f706b36195 | 57 | char minuteBuf[3]; |
kkizirian | 0:72f706b36195 | 58 | sprintf(hourBuf, "%i", hour); |
kkizirian | 0:72f706b36195 | 59 | sprintf(minuteBuf, "%i", minute); |
kkizirian | 0:72f706b36195 | 60 | |
kkizirian | 0:72f706b36195 | 61 | string hourStr = hourBuf; |
kkizirian | 0:72f706b36195 | 62 | string minuteStr = minuteBuf; |
kkizirian | 1:b02713ff0bd5 | 63 | |
kkizirian | 1:b02713ff0bd5 | 64 | if (this->getHour() < 10) |
kkizirian | 1:b02713ff0bd5 | 65 | hourStr = "0" + hourStr; |
kkizirian | 1:b02713ff0bd5 | 66 | |
kkizirian | 1:b02713ff0bd5 | 67 | if (this->getMinute() < 10) |
kkizirian | 1:b02713ff0bd5 | 68 | minuteStr = "0" + minuteStr; |
kkizirian | 0:72f706b36195 | 69 | |
kkizirian | 0:72f706b36195 | 70 | output = this->getAbbreviatedName() + "," + hourStr + "," + |
kkizirian | 0:72f706b36195 | 71 | minuteStr + "," + this->getAMPM(); |
kkizirian | 0:72f706b36195 | 72 | return output; |
kkizirian | 0:72f706b36195 | 73 | } |
kkizirian | 0:72f706b36195 | 74 | |
kkizirian | 0:72f706b36195 | 75 | string Course :: getDisplayString() { |
kkizirian | 0:72f706b36195 | 76 | string output = ""; |
kkizirian | 0:72f706b36195 | 77 | char hourBuf[3]; |
kkizirian | 0:72f706b36195 | 78 | char minuteBuf[3]; |
kkizirian | 0:72f706b36195 | 79 | sprintf(hourBuf, "%i", hour); |
kkizirian | 0:72f706b36195 | 80 | sprintf(minuteBuf, "%i", minute); |
kkizirian | 0:72f706b36195 | 81 | |
kkizirian | 0:72f706b36195 | 82 | string hourStr = hourBuf; |
kkizirian | 0:72f706b36195 | 83 | string minuteStr = minuteBuf; |
kkizirian | 0:72f706b36195 | 84 | |
kkizirian | 0:72f706b36195 | 85 | if (this->getMinute() < 10) { |
kkizirian | 0:72f706b36195 | 86 | minuteStr = "0" + minuteStr; |
kkizirian | 0:72f706b36195 | 87 | } |
kkizirian | 0:72f706b36195 | 88 | |
kkizirian | 0:72f706b36195 | 89 | output = this->getFullName() + " at " + hourStr + ":" + minuteStr + " " + this->getAMPM(); |
kkizirian | 0:72f706b36195 | 90 | return output; |
kkizirian | 0:72f706b36195 | 91 | } |
kkizirian | 0:72f706b36195 | 92 | |
kkizirian | 0:72f706b36195 | 93 | void Course :: createBuildingMaps() { |
kkizirian | 0:72f706b36195 | 94 | buildingLAT["ALN"] = 33.776078; buildingLONG["ALN"] = -84.398785; |
kkizirian | 0:72f706b36195 | 95 | buildingNames["ALN"] = "Allen"; |
kkizirian | 0:72f706b36195 | 96 | buildingLAT["BUR"] = 33.775660; buildingLONG["BUR"] = -84.398222; |
kkizirian | 0:72f706b36195 | 97 | buildingNames["BUR"] = "Burger-Henry"; |
kkizirian | 0:72f706b36195 | 98 | buildingLAT["CAD"] = 33.776631; buildingLONG["CAD"] = -84.396969; |
kkizirian | 0:72f706b36195 | 99 | buildingNames["CAD"] = "Caddell"; |
kkizirian | 0:72f706b36195 | 100 | buildingLAT["CHR"] = 33.777959; buildingLONG["CHR"] = -84.397051; |
kkizirian | 0:72f706b36195 | 101 | buildingNames["CHR"] = "Cherry"; |
kkizirian | 0:72f706b36195 | 102 | buildingLAT["CLH"] = 33.774801; buildingLONG["CLH"] = -84.396376; |
kkizirian | 0:72f706b36195 | 103 | buildingNames["CLH"] = "Clough"; |
kkizirian | 0:72f706b36195 | 104 | buildingLAT["COC"] = 33.777442; buildingLONG["COC"] = -84.397259; |
kkizirian | 0:72f706b36195 | 105 | buildingNames["COC"] = "College of Computing"; |
kkizirian | 0:72f706b36195 | 106 | buildingLAT["COD"] = 33.776010; buildingLONG["COD"] = -84.395561; |
kkizirian | 0:72f706b36195 | 107 | buildingNames["COD"] = "College of Design"; |
kkizirian | 0:72f706b36195 | 108 | buildingLAT["COO"] = 33.772724; buildingLONG["COO"] = -84.395770; |
kkizirian | 0:72f706b36195 | 109 | buildingNames["COO"] = "Coon Building"; |
kkizirian | 0:72f706b36195 | 110 | buildingLAT["CCH"] = 33.778216; buildingLONG["CCH"] = -84.404506; |
kkizirian | 0:72f706b36195 | 111 | buildingNames["CCH"] = "Couch"; |
kkizirian | 0:72f706b36195 | 112 | buildingLAT["FOR"] = 33.778843; buildingLONG["FOR"] = -84.395849; |
kkizirian | 0:72f706b36195 | 113 | buildingNames["FOR"] = "Ford"; |
kkizirian | 0:72f706b36195 | 114 | buildingLAT["GUG"] = 33.771628; buildingLONG["GUG"] = -84.395775; |
kkizirian | 0:72f706b36195 | 115 | buildingNames["GUG"] = "Guggenheim"; |
kkizirian | 0:72f706b36195 | 116 | buildingLAT["HWY"] = 33.777498; buildingLONG["HWY"] = -84.398582; |
kkizirian | 0:72f706b36195 | 117 | buildingNames["HWY"] = "Howey"; |
kkizirian | 0:72f706b36195 | 118 | buildingLAT["ICR"] = 33.775448; buildingLONG["ICR"] = -84.401261; |
kkizirian | 0:72f706b36195 | 119 | buildingNames["ICR"] = "Instructional Center"; |
kkizirian | 0:72f706b36195 | 120 | buildingLAT["IVN"] = 33.774001; buildingLONG["IVN"] = -84.404259; |
kkizirian | 0:72f706b36195 | 121 | buildingNames["IVN"] = "Ivan Allen"; |
kkizirian | 0:72f706b36195 | 122 | buildingLAT["KLS"] = 33.777244; buildingLONG["KLS"] = -84.396256; |
kkizirian | 0:72f706b36195 | 123 | buildingNames["KLS"] = "Klaus"; |
kkizirian | 0:72f706b36195 | 124 | buildingLAT["LVE"] = 33.776730; buildingLONG["LVE"] = -84.401807; |
kkizirian | 0:72f706b36195 | 125 | buildingNames["LVE"] = "Love"; |
kkizirian | 0:72f706b36195 | 126 | buildingLAT["MCS"] = 33.779068; buildingLONG["MCS"] = -84.398651; |
kkizirian | 0:72f706b36195 | 127 | buildingNames["MCS"] = "Marcus Nanotech"; |
kkizirian | 0:72f706b36195 | 128 | buildingLAT["MSN"] = 33.776685; buildingLONG["MSN"] = -84.398896; |
kkizirian | 0:72f706b36195 | 129 | buildingNames["MSN"] = "Mason"; |
kkizirian | 0:72f706b36195 | 130 | buildingLAT["PET"] = 33.778946; buildingLONG["PET"] = -84.397158; |
kkizirian | 0:72f706b36195 | 131 | buildingNames["PET"] = "Petit"; |
kkizirian | 0:72f706b36195 | 132 | buildingLAT["SCH"] = 33.776562; buildingLONG["SCH"] = -84.388060; |
kkizirian | 0:72f706b36195 | 133 | buildingNames["SCH"] = "Scheller"; |
kkizirian | 0:72f706b36195 | 134 | buildingLAT["SKI"] = 33.773603; buildingLONG["SKI"] = -84.395897; |
kkizirian | 0:72f706b36195 | 135 | buildingNames["SKI"] = "Skiles"; |
kkizirian | 0:72f706b36195 | 136 | buildingLAT["VAN"] = 33.776000; buildingLONG["VAN"] = -84.397132; |
kkizirian | 0:72f706b36195 | 137 | buildingNames["VAN"] = "Van Leer"; |
kkizirian | 0:72f706b36195 | 138 | } |