Class that holds Course information

Dependents:   Course_Example course_input class_finder

Committer:
kkizirian
Date:
Wed Dec 07 17:57:11 2016 +0000
Revision:
4:bc4b05dacca3
Parent:
3:e2024ec77d96
Child:
5:7d792c9848bb
Added getHour_toString()

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kkizirian 0:72f706b36195 1 #include "Course.h"
kkizirian 0:72f706b36195 2 #include <string>
kkizirian 0:72f706b36195 3
kkizirian 2:8f163dc0b6c4 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 2:8f163dc0b6c4 8 m["KLS"] = 33.777244;
kkizirian 2:8f163dc0b6c4 9 m["VAN"] = 33.776000;
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 2:8f163dc0b6c4 15 m["CLH"] = -84.396376;
kkizirian 2:8f163dc0b6c4 16 m["COC"] = -84.397259;
kkizirian 2:8f163dc0b6c4 17 m["KLS"] = -84.396256;
kkizirian 2:8f163dc0b6c4 18 m["VAN"] = -84.397132;
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 2:8f163dc0b6c4 29 }
kkizirian 2:8f163dc0b6c4 30
kkizirian 2:8f163dc0b6c4 31 map<string, float> Course::buildingLAT = create_lat_map();
kkizirian 2:8f163dc0b6c4 32 map<string, float> Course::buildingLONG = create_long_map();
kkizirian 2:8f163dc0b6c4 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 2:8f163dc0b6c4 36 //createBuildingMaps();
kkizirian 0:72f706b36195 37 abbreviatedName = pAbbreviatedName;
kkizirian 0:72f706b36195 38 fullName = buildingNames[pAbbreviatedName];
kkizirian 0:72f706b36195 39 latitude = buildingLAT[pAbbreviatedName];
kkizirian 0:72f706b36195 40 longitude = buildingLONG[pAbbreviatedName];
kkizirian 0:72f706b36195 41 ampm = pAMPM;
kkizirian 0:72f706b36195 42 hour = pHour;
kkizirian 0:72f706b36195 43 minute = pMinute;
kkizirian 0:72f706b36195 44 }
kkizirian 0:72f706b36195 45
kkizirian 0:72f706b36195 46 string Course :: getAbbreviatedName() {
kkizirian 0:72f706b36195 47 return abbreviatedName;
kkizirian 0:72f706b36195 48 }
kkizirian 0:72f706b36195 49
kkizirian 0:72f706b36195 50 string Course :: getFullName() {
kkizirian 0:72f706b36195 51 return fullName;
kkizirian 0:72f706b36195 52 }
kkizirian 0:72f706b36195 53
kkizirian 0:72f706b36195 54 int Course :: getHour() {
kkizirian 0:72f706b36195 55 return hour;
kkizirian 0:72f706b36195 56 }
kkizirian 0:72f706b36195 57
kkizirian 2:8f163dc0b6c4 58 int Course :: getHour_forCompare() {
kkizirian 2:8f163dc0b6c4 59 if (hour == 12)
kkizirian 2:8f163dc0b6c4 60 return 0;
kkizirian 2:8f163dc0b6c4 61 else
kkizirian 3:e2024ec77d96 62 return hour;
kkizirian 2:8f163dc0b6c4 63 }
kkizirian 2:8f163dc0b6c4 64
kkizirian 4:bc4b05dacca3 65 string Course :: getHour_toString() {
kkizirian 4:bc4b05dacca3 66 char hourBuf[3];
kkizirian 4:bc4b05dacca3 67 sprintf(hourBuf, "%i", hour);
kkizirian 4:bc4b05dacca3 68 hourBuf[2] = '\0';
kkizirian 4:bc4b05dacca3 69
kkizirian 4:bc4b05dacca3 70 string hourStr = hourBuf;
kkizirian 4:bc4b05dacca3 71
kkizirian 4:bc4b05dacca3 72 if (this->getHour() < 10)
kkizirian 4:bc4b05dacca3 73 hourStr = "0" + hourStr;
kkizirian 4:bc4b05dacca3 74
kkizirian 4:bc4b05dacca3 75 return hourStr;
kkizirian 4:bc4b05dacca3 76 }
kkizirian 4:bc4b05dacca3 77
kkizirian 0:72f706b36195 78 int Course :: getMinute() {
kkizirian 0:72f706b36195 79 return minute;
kkizirian 0:72f706b36195 80 }
kkizirian 0:72f706b36195 81
kkizirian 0:72f706b36195 82 float Course :: getLat() {
kkizirian 0:72f706b36195 83 return latitude;
kkizirian 0:72f706b36195 84 }
kkizirian 0:72f706b36195 85
kkizirian 0:72f706b36195 86 float Course :: getLong() {
kkizirian 0:72f706b36195 87 return longitude;
kkizirian 0:72f706b36195 88 }
kkizirian 0:72f706b36195 89
kkizirian 0:72f706b36195 90 string Course :: getAMPM() {
kkizirian 0:72f706b36195 91 return ampm;
kkizirian 0:72f706b36195 92 }
kkizirian 0:72f706b36195 93
kkizirian 0:72f706b36195 94 int Course :: getAMPM_toInt() {
kkizirian 0:72f706b36195 95 if (ampm == "AM")
kkizirian 0:72f706b36195 96 return 0;
kkizirian 0:72f706b36195 97 else
kkizirian 0:72f706b36195 98 return 1;
kkizirian 0:72f706b36195 99 }
kkizirian 0:72f706b36195 100
kkizirian 0:72f706b36195 101 string Course :: getFileString() {
kkizirian 0:72f706b36195 102 string output = "";
kkizirian 0:72f706b36195 103 char hourBuf[3];
kkizirian 0:72f706b36195 104 char minuteBuf[3];
kkizirian 0:72f706b36195 105 sprintf(hourBuf, "%i", hour);
kkizirian 0:72f706b36195 106 sprintf(minuteBuf, "%i", minute);
kkizirian 0:72f706b36195 107
kkizirian 0:72f706b36195 108 string hourStr = hourBuf;
kkizirian 0:72f706b36195 109 string minuteStr = minuteBuf;
kkizirian 1:b02713ff0bd5 110
kkizirian 1:b02713ff0bd5 111 if (this->getHour() < 10)
kkizirian 1:b02713ff0bd5 112 hourStr = "0" + hourStr;
kkizirian 1:b02713ff0bd5 113
kkizirian 1:b02713ff0bd5 114 if (this->getMinute() < 10)
kkizirian 1:b02713ff0bd5 115 minuteStr = "0" + minuteStr;
kkizirian 0:72f706b36195 116
kkizirian 0:72f706b36195 117 output = this->getAbbreviatedName() + "," + hourStr + "," +
kkizirian 0:72f706b36195 118 minuteStr + "," + this->getAMPM();
kkizirian 0:72f706b36195 119 return output;
kkizirian 0:72f706b36195 120 }
kkizirian 0:72f706b36195 121
kkizirian 0:72f706b36195 122 string Course :: getDisplayString() {
kkizirian 0:72f706b36195 123 string output = "";
kkizirian 0:72f706b36195 124 char hourBuf[3];
kkizirian 0:72f706b36195 125 char minuteBuf[3];
kkizirian 0:72f706b36195 126 sprintf(hourBuf, "%i", hour);
kkizirian 0:72f706b36195 127 sprintf(minuteBuf, "%i", minute);
kkizirian 0:72f706b36195 128
kkizirian 0:72f706b36195 129 string hourStr = hourBuf;
kkizirian 0:72f706b36195 130 string minuteStr = minuteBuf;
kkizirian 0:72f706b36195 131
kkizirian 0:72f706b36195 132 if (this->getMinute() < 10) {
kkizirian 0:72f706b36195 133 minuteStr = "0" + minuteStr;
kkizirian 0:72f706b36195 134 }
kkizirian 0:72f706b36195 135
kkizirian 4:bc4b05dacca3 136 output = this->getFullName() + " at " + hourStr + ":" + minuteStr + "" + this->getAMPM();
kkizirian 0:72f706b36195 137 return output;
kkizirian 0:72f706b36195 138 }
kkizirian 2:8f163dc0b6c4 139 /*
kkizirian 0:72f706b36195 140 void Course :: createBuildingMaps() {
kkizirian 0:72f706b36195 141 buildingLAT["ALN"] = 33.776078; buildingLONG["ALN"] = -84.398785;
kkizirian 0:72f706b36195 142 buildingNames["ALN"] = "Allen";
kkizirian 0:72f706b36195 143 buildingLAT["BUR"] = 33.775660; buildingLONG["BUR"] = -84.398222;
kkizirian 0:72f706b36195 144 buildingNames["BUR"] = "Burger-Henry";
kkizirian 0:72f706b36195 145 buildingLAT["CAD"] = 33.776631; buildingLONG["CAD"] = -84.396969;
kkizirian 0:72f706b36195 146 buildingNames["CAD"] = "Caddell";
kkizirian 0:72f706b36195 147 buildingLAT["CHR"] = 33.777959; buildingLONG["CHR"] = -84.397051;
kkizirian 0:72f706b36195 148 buildingNames["CHR"] = "Cherry";
kkizirian 0:72f706b36195 149 buildingLAT["CLH"] = 33.774801; buildingLONG["CLH"] = -84.396376;
kkizirian 0:72f706b36195 150 buildingNames["CLH"] = "Clough";
kkizirian 0:72f706b36195 151 buildingLAT["COC"] = 33.777442; buildingLONG["COC"] = -84.397259;
kkizirian 0:72f706b36195 152 buildingNames["COC"] = "College of Computing";
kkizirian 0:72f706b36195 153 buildingLAT["COD"] = 33.776010; buildingLONG["COD"] = -84.395561;
kkizirian 0:72f706b36195 154 buildingNames["COD"] = "College of Design";
kkizirian 0:72f706b36195 155 buildingLAT["COO"] = 33.772724; buildingLONG["COO"] = -84.395770;
kkizirian 0:72f706b36195 156 buildingNames["COO"] = "Coon Building";
kkizirian 0:72f706b36195 157 buildingLAT["CCH"] = 33.778216; buildingLONG["CCH"] = -84.404506;
kkizirian 0:72f706b36195 158 buildingNames["CCH"] = "Couch";
kkizirian 0:72f706b36195 159 buildingLAT["FOR"] = 33.778843; buildingLONG["FOR"] = -84.395849;
kkizirian 0:72f706b36195 160 buildingNames["FOR"] = "Ford";
kkizirian 0:72f706b36195 161 buildingLAT["GUG"] = 33.771628; buildingLONG["GUG"] = -84.395775;
kkizirian 0:72f706b36195 162 buildingNames["GUG"] = "Guggenheim";
kkizirian 0:72f706b36195 163 buildingLAT["HWY"] = 33.777498; buildingLONG["HWY"] = -84.398582;
kkizirian 0:72f706b36195 164 buildingNames["HWY"] = "Howey";
kkizirian 0:72f706b36195 165 buildingLAT["ICR"] = 33.775448; buildingLONG["ICR"] = -84.401261;
kkizirian 0:72f706b36195 166 buildingNames["ICR"] = "Instructional Center";
kkizirian 0:72f706b36195 167 buildingLAT["IVN"] = 33.774001; buildingLONG["IVN"] = -84.404259;
kkizirian 0:72f706b36195 168 buildingNames["IVN"] = "Ivan Allen";
kkizirian 0:72f706b36195 169 buildingLAT["KLS"] = 33.777244; buildingLONG["KLS"] = -84.396256;
kkizirian 0:72f706b36195 170 buildingNames["KLS"] = "Klaus";
kkizirian 0:72f706b36195 171 buildingLAT["LVE"] = 33.776730; buildingLONG["LVE"] = -84.401807;
kkizirian 0:72f706b36195 172 buildingNames["LVE"] = "Love";
kkizirian 0:72f706b36195 173 buildingLAT["MCS"] = 33.779068; buildingLONG["MCS"] = -84.398651;
kkizirian 0:72f706b36195 174 buildingNames["MCS"] = "Marcus Nanotech";
kkizirian 0:72f706b36195 175 buildingLAT["MSN"] = 33.776685; buildingLONG["MSN"] = -84.398896;
kkizirian 0:72f706b36195 176 buildingNames["MSN"] = "Mason";
kkizirian 0:72f706b36195 177 buildingLAT["PET"] = 33.778946; buildingLONG["PET"] = -84.397158;
kkizirian 0:72f706b36195 178 buildingNames["PET"] = "Petit";
kkizirian 0:72f706b36195 179 buildingLAT["SCH"] = 33.776562; buildingLONG["SCH"] = -84.388060;
kkizirian 0:72f706b36195 180 buildingNames["SCH"] = "Scheller";
kkizirian 0:72f706b36195 181 buildingLAT["SKI"] = 33.773603; buildingLONG["SKI"] = -84.395897;
kkizirian 0:72f706b36195 182 buildingNames["SKI"] = "Skiles";
kkizirian 0:72f706b36195 183 buildingLAT["VAN"] = 33.776000; buildingLONG["VAN"] = -84.397132;
kkizirian 0:72f706b36195 184 buildingNames["VAN"] = "Van Leer";
kkizirian 2:8f163dc0b6c4 185 }*/