Class that holds Course information

Dependents:   Course_Example course_input class_finder

Committer:
kkizirian
Date:
Wed Dec 07 01:41:40 2016 +0000
Revision:
2:8f163dc0b6c4
Parent:
1:b02713ff0bd5
Child:
3:e2024ec77d96
Cut out some classes to save memory and added a getHour_forCompare() function to handle the case where the hour is 12.

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 2:8f163dc0b6c4 25 m["COC"] = "College of Computing";
kkizirian 2:8f163dc0b6c4 26 m["KLS"] = "Klaus";
kkizirian 2:8f163dc0b6c4 27 m["VAN"] = "Van Leer";
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 2:8f163dc0b6c4 62 return 1;
kkizirian 2:8f163dc0b6c4 63 }
kkizirian 2:8f163dc0b6c4 64
kkizirian 0:72f706b36195 65 int Course :: getMinute() {
kkizirian 0:72f706b36195 66 return minute;
kkizirian 0:72f706b36195 67 }
kkizirian 0:72f706b36195 68
kkizirian 0:72f706b36195 69 float Course :: getLat() {
kkizirian 0:72f706b36195 70 return latitude;
kkizirian 0:72f706b36195 71 }
kkizirian 0:72f706b36195 72
kkizirian 0:72f706b36195 73 float Course :: getLong() {
kkizirian 0:72f706b36195 74 return longitude;
kkizirian 0:72f706b36195 75 }
kkizirian 0:72f706b36195 76
kkizirian 0:72f706b36195 77 string Course :: getAMPM() {
kkizirian 0:72f706b36195 78 return ampm;
kkizirian 0:72f706b36195 79 }
kkizirian 0:72f706b36195 80
kkizirian 0:72f706b36195 81 int Course :: getAMPM_toInt() {
kkizirian 0:72f706b36195 82 if (ampm == "AM")
kkizirian 0:72f706b36195 83 return 0;
kkizirian 0:72f706b36195 84 else
kkizirian 0:72f706b36195 85 return 1;
kkizirian 0:72f706b36195 86 }
kkizirian 0:72f706b36195 87
kkizirian 0:72f706b36195 88 string Course :: getFileString() {
kkizirian 0:72f706b36195 89 string output = "";
kkizirian 0:72f706b36195 90 char hourBuf[3];
kkizirian 0:72f706b36195 91 char minuteBuf[3];
kkizirian 0:72f706b36195 92 sprintf(hourBuf, "%i", hour);
kkizirian 0:72f706b36195 93 sprintf(minuteBuf, "%i", minute);
kkizirian 0:72f706b36195 94
kkizirian 0:72f706b36195 95 string hourStr = hourBuf;
kkizirian 0:72f706b36195 96 string minuteStr = minuteBuf;
kkizirian 1:b02713ff0bd5 97
kkizirian 1:b02713ff0bd5 98 if (this->getHour() < 10)
kkizirian 1:b02713ff0bd5 99 hourStr = "0" + hourStr;
kkizirian 1:b02713ff0bd5 100
kkizirian 1:b02713ff0bd5 101 if (this->getMinute() < 10)
kkizirian 1:b02713ff0bd5 102 minuteStr = "0" + minuteStr;
kkizirian 0:72f706b36195 103
kkizirian 0:72f706b36195 104 output = this->getAbbreviatedName() + "," + hourStr + "," +
kkizirian 0:72f706b36195 105 minuteStr + "," + this->getAMPM();
kkizirian 0:72f706b36195 106 return output;
kkizirian 0:72f706b36195 107 }
kkizirian 0:72f706b36195 108
kkizirian 0:72f706b36195 109 string Course :: getDisplayString() {
kkizirian 0:72f706b36195 110 string output = "";
kkizirian 0:72f706b36195 111 char hourBuf[3];
kkizirian 0:72f706b36195 112 char minuteBuf[3];
kkizirian 0:72f706b36195 113 sprintf(hourBuf, "%i", hour);
kkizirian 0:72f706b36195 114 sprintf(minuteBuf, "%i", minute);
kkizirian 0:72f706b36195 115
kkizirian 0:72f706b36195 116 string hourStr = hourBuf;
kkizirian 0:72f706b36195 117 string minuteStr = minuteBuf;
kkizirian 0:72f706b36195 118
kkizirian 0:72f706b36195 119 if (this->getMinute() < 10) {
kkizirian 0:72f706b36195 120 minuteStr = "0" + minuteStr;
kkizirian 0:72f706b36195 121 }
kkizirian 0:72f706b36195 122
kkizirian 0:72f706b36195 123 output = this->getFullName() + " at " + hourStr + ":" + minuteStr + " " + this->getAMPM();
kkizirian 0:72f706b36195 124 return output;
kkizirian 0:72f706b36195 125 }
kkizirian 2:8f163dc0b6c4 126 /*
kkizirian 0:72f706b36195 127 void Course :: createBuildingMaps() {
kkizirian 0:72f706b36195 128 buildingLAT["ALN"] = 33.776078; buildingLONG["ALN"] = -84.398785;
kkizirian 0:72f706b36195 129 buildingNames["ALN"] = "Allen";
kkizirian 0:72f706b36195 130 buildingLAT["BUR"] = 33.775660; buildingLONG["BUR"] = -84.398222;
kkizirian 0:72f706b36195 131 buildingNames["BUR"] = "Burger-Henry";
kkizirian 0:72f706b36195 132 buildingLAT["CAD"] = 33.776631; buildingLONG["CAD"] = -84.396969;
kkizirian 0:72f706b36195 133 buildingNames["CAD"] = "Caddell";
kkizirian 0:72f706b36195 134 buildingLAT["CHR"] = 33.777959; buildingLONG["CHR"] = -84.397051;
kkizirian 0:72f706b36195 135 buildingNames["CHR"] = "Cherry";
kkizirian 0:72f706b36195 136 buildingLAT["CLH"] = 33.774801; buildingLONG["CLH"] = -84.396376;
kkizirian 0:72f706b36195 137 buildingNames["CLH"] = "Clough";
kkizirian 0:72f706b36195 138 buildingLAT["COC"] = 33.777442; buildingLONG["COC"] = -84.397259;
kkizirian 0:72f706b36195 139 buildingNames["COC"] = "College of Computing";
kkizirian 0:72f706b36195 140 buildingLAT["COD"] = 33.776010; buildingLONG["COD"] = -84.395561;
kkizirian 0:72f706b36195 141 buildingNames["COD"] = "College of Design";
kkizirian 0:72f706b36195 142 buildingLAT["COO"] = 33.772724; buildingLONG["COO"] = -84.395770;
kkizirian 0:72f706b36195 143 buildingNames["COO"] = "Coon Building";
kkizirian 0:72f706b36195 144 buildingLAT["CCH"] = 33.778216; buildingLONG["CCH"] = -84.404506;
kkizirian 0:72f706b36195 145 buildingNames["CCH"] = "Couch";
kkizirian 0:72f706b36195 146 buildingLAT["FOR"] = 33.778843; buildingLONG["FOR"] = -84.395849;
kkizirian 0:72f706b36195 147 buildingNames["FOR"] = "Ford";
kkizirian 0:72f706b36195 148 buildingLAT["GUG"] = 33.771628; buildingLONG["GUG"] = -84.395775;
kkizirian 0:72f706b36195 149 buildingNames["GUG"] = "Guggenheim";
kkizirian 0:72f706b36195 150 buildingLAT["HWY"] = 33.777498; buildingLONG["HWY"] = -84.398582;
kkizirian 0:72f706b36195 151 buildingNames["HWY"] = "Howey";
kkizirian 0:72f706b36195 152 buildingLAT["ICR"] = 33.775448; buildingLONG["ICR"] = -84.401261;
kkizirian 0:72f706b36195 153 buildingNames["ICR"] = "Instructional Center";
kkizirian 0:72f706b36195 154 buildingLAT["IVN"] = 33.774001; buildingLONG["IVN"] = -84.404259;
kkizirian 0:72f706b36195 155 buildingNames["IVN"] = "Ivan Allen";
kkizirian 0:72f706b36195 156 buildingLAT["KLS"] = 33.777244; buildingLONG["KLS"] = -84.396256;
kkizirian 0:72f706b36195 157 buildingNames["KLS"] = "Klaus";
kkizirian 0:72f706b36195 158 buildingLAT["LVE"] = 33.776730; buildingLONG["LVE"] = -84.401807;
kkizirian 0:72f706b36195 159 buildingNames["LVE"] = "Love";
kkizirian 0:72f706b36195 160 buildingLAT["MCS"] = 33.779068; buildingLONG["MCS"] = -84.398651;
kkizirian 0:72f706b36195 161 buildingNames["MCS"] = "Marcus Nanotech";
kkizirian 0:72f706b36195 162 buildingLAT["MSN"] = 33.776685; buildingLONG["MSN"] = -84.398896;
kkizirian 0:72f706b36195 163 buildingNames["MSN"] = "Mason";
kkizirian 0:72f706b36195 164 buildingLAT["PET"] = 33.778946; buildingLONG["PET"] = -84.397158;
kkizirian 0:72f706b36195 165 buildingNames["PET"] = "Petit";
kkizirian 0:72f706b36195 166 buildingLAT["SCH"] = 33.776562; buildingLONG["SCH"] = -84.388060;
kkizirian 0:72f706b36195 167 buildingNames["SCH"] = "Scheller";
kkizirian 0:72f706b36195 168 buildingLAT["SKI"] = 33.773603; buildingLONG["SKI"] = -84.395897;
kkizirian 0:72f706b36195 169 buildingNames["SKI"] = "Skiles";
kkizirian 0:72f706b36195 170 buildingLAT["VAN"] = 33.776000; buildingLONG["VAN"] = -84.397132;
kkizirian 0:72f706b36195 171 buildingNames["VAN"] = "Van Leer";
kkizirian 2:8f163dc0b6c4 172 }*/