Class that holds Course information

Dependents:   Course_Example course_input class_finder

Committer:
kkizirian
Date:
Mon Dec 05 00:31:29 2016 +0000
Revision:
0:72f706b36195
Child:
1:b02713ff0bd5
first commit

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 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 0:72f706b36195 63
kkizirian 0:72f706b36195 64 output = this->getAbbreviatedName() + "," + hourStr + "," +
kkizirian 0:72f706b36195 65 minuteStr + "," + this->getAMPM();
kkizirian 0:72f706b36195 66 return output;
kkizirian 0:72f706b36195 67 }
kkizirian 0:72f706b36195 68
kkizirian 0:72f706b36195 69 string Course :: getDisplayString() {
kkizirian 0:72f706b36195 70 string output = "";
kkizirian 0:72f706b36195 71 char hourBuf[3];
kkizirian 0:72f706b36195 72 char minuteBuf[3];
kkizirian 0:72f706b36195 73 sprintf(hourBuf, "%i", hour);
kkizirian 0:72f706b36195 74 sprintf(minuteBuf, "%i", minute);
kkizirian 0:72f706b36195 75
kkizirian 0:72f706b36195 76 string hourStr = hourBuf;
kkizirian 0:72f706b36195 77 string minuteStr = minuteBuf;
kkizirian 0:72f706b36195 78
kkizirian 0:72f706b36195 79 if (this->getMinute() < 10) {
kkizirian 0:72f706b36195 80 minuteStr = "0" + minuteStr;
kkizirian 0:72f706b36195 81 }
kkizirian 0:72f706b36195 82
kkizirian 0:72f706b36195 83 output = this->getFullName() + " at " + hourStr + ":" + minuteStr + " " + this->getAMPM();
kkizirian 0:72f706b36195 84 return output;
kkizirian 0:72f706b36195 85 }
kkizirian 0:72f706b36195 86
kkizirian 0:72f706b36195 87 void Course :: createBuildingMaps() {
kkizirian 0:72f706b36195 88 buildingLAT["ALN"] = 33.776078; buildingLONG["ALN"] = -84.398785;
kkizirian 0:72f706b36195 89 buildingNames["ALN"] = "Allen";
kkizirian 0:72f706b36195 90 buildingLAT["BUR"] = 33.775660; buildingLONG["BUR"] = -84.398222;
kkizirian 0:72f706b36195 91 buildingNames["BUR"] = "Burger-Henry";
kkizirian 0:72f706b36195 92 buildingLAT["CAD"] = 33.776631; buildingLONG["CAD"] = -84.396969;
kkizirian 0:72f706b36195 93 buildingNames["CAD"] = "Caddell";
kkizirian 0:72f706b36195 94 buildingLAT["CHR"] = 33.777959; buildingLONG["CHR"] = -84.397051;
kkizirian 0:72f706b36195 95 buildingNames["CHR"] = "Cherry";
kkizirian 0:72f706b36195 96 buildingLAT["CLH"] = 33.774801; buildingLONG["CLH"] = -84.396376;
kkizirian 0:72f706b36195 97 buildingNames["CLH"] = "Clough";
kkizirian 0:72f706b36195 98 buildingLAT["COC"] = 33.777442; buildingLONG["COC"] = -84.397259;
kkizirian 0:72f706b36195 99 buildingNames["COC"] = "College of Computing";
kkizirian 0:72f706b36195 100 buildingLAT["COD"] = 33.776010; buildingLONG["COD"] = -84.395561;
kkizirian 0:72f706b36195 101 buildingNames["COD"] = "College of Design";
kkizirian 0:72f706b36195 102 buildingLAT["COO"] = 33.772724; buildingLONG["COO"] = -84.395770;
kkizirian 0:72f706b36195 103 buildingNames["COO"] = "Coon Building";
kkizirian 0:72f706b36195 104 buildingLAT["CCH"] = 33.778216; buildingLONG["CCH"] = -84.404506;
kkizirian 0:72f706b36195 105 buildingNames["CCH"] = "Couch";
kkizirian 0:72f706b36195 106 buildingLAT["FOR"] = 33.778843; buildingLONG["FOR"] = -84.395849;
kkizirian 0:72f706b36195 107 buildingNames["FOR"] = "Ford";
kkizirian 0:72f706b36195 108 buildingLAT["GUG"] = 33.771628; buildingLONG["GUG"] = -84.395775;
kkizirian 0:72f706b36195 109 buildingNames["GUG"] = "Guggenheim";
kkizirian 0:72f706b36195 110 buildingLAT["HWY"] = 33.777498; buildingLONG["HWY"] = -84.398582;
kkizirian 0:72f706b36195 111 buildingNames["HWY"] = "Howey";
kkizirian 0:72f706b36195 112 buildingLAT["ICR"] = 33.775448; buildingLONG["ICR"] = -84.401261;
kkizirian 0:72f706b36195 113 buildingNames["ICR"] = "Instructional Center";
kkizirian 0:72f706b36195 114 buildingLAT["IVN"] = 33.774001; buildingLONG["IVN"] = -84.404259;
kkizirian 0:72f706b36195 115 buildingNames["IVN"] = "Ivan Allen";
kkizirian 0:72f706b36195 116 buildingLAT["KLS"] = 33.777244; buildingLONG["KLS"] = -84.396256;
kkizirian 0:72f706b36195 117 buildingNames["KLS"] = "Klaus";
kkizirian 0:72f706b36195 118 buildingLAT["LVE"] = 33.776730; buildingLONG["LVE"] = -84.401807;
kkizirian 0:72f706b36195 119 buildingNames["LVE"] = "Love";
kkizirian 0:72f706b36195 120 buildingLAT["MCS"] = 33.779068; buildingLONG["MCS"] = -84.398651;
kkizirian 0:72f706b36195 121 buildingNames["MCS"] = "Marcus Nanotech";
kkizirian 0:72f706b36195 122 buildingLAT["MSN"] = 33.776685; buildingLONG["MSN"] = -84.398896;
kkizirian 0:72f706b36195 123 buildingNames["MSN"] = "Mason";
kkizirian 0:72f706b36195 124 buildingLAT["PET"] = 33.778946; buildingLONG["PET"] = -84.397158;
kkizirian 0:72f706b36195 125 buildingNames["PET"] = "Petit";
kkizirian 0:72f706b36195 126 buildingLAT["SCH"] = 33.776562; buildingLONG["SCH"] = -84.388060;
kkizirian 0:72f706b36195 127 buildingNames["SCH"] = "Scheller";
kkizirian 0:72f706b36195 128 buildingLAT["SKI"] = 33.773603; buildingLONG["SKI"] = -84.395897;
kkizirian 0:72f706b36195 129 buildingNames["SKI"] = "Skiles";
kkizirian 0:72f706b36195 130 buildingLAT["VAN"] = 33.776000; buildingLONG["VAN"] = -84.397132;
kkizirian 0:72f706b36195 131 buildingNames["VAN"] = "Van Leer";
kkizirian 0:72f706b36195 132 }