diff options
author | Matt Strapp <matt@mattstrapp.net> | 2021-10-11 20:02:46 -0500 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2021-10-11 20:02:46 -0500 |
commit | aa2a4faf537c9bc7e2e87ff38483e2bf53ed24cf (patch) | |
tree | d5049549bcb1fed21d118c200ae40bac7e1ebbcc /dev/a3-earthquake/earthquake.cc | |
parent | Fix gnu's stupidity (diff) | |
parent | Publish a3 (diff) | |
download | csci4611-aa2a4faf537c9bc7e2e87ff38483e2bf53ed24cf.tar csci4611-aa2a4faf537c9bc7e2e87ff38483e2bf53ed24cf.tar.gz csci4611-aa2a4faf537c9bc7e2e87ff38483e2bf53ed24cf.tar.bz2 csci4611-aa2a4faf537c9bc7e2e87ff38483e2bf53ed24cf.tar.lz csci4611-aa2a4faf537c9bc7e2e87ff38483e2bf53ed24cf.tar.xz csci4611-aa2a4faf537c9bc7e2e87ff38483e2bf53ed24cf.tar.zst csci4611-aa2a4faf537c9bc7e2e87ff38483e2bf53ed24cf.zip |
Merge branch 'support-code' of github.umn.edu:umn-csci-4611-f21/shared-upstream
Diffstat (limited to '')
-rw-r--r-- | dev/a3-earthquake/earthquake.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/dev/a3-earthquake/earthquake.cc b/dev/a3-earthquake/earthquake.cc new file mode 100644 index 0000000..cf4a75a --- /dev/null +++ b/dev/a3-earthquake/earthquake.cc @@ -0,0 +1,50 @@ +/** CSci-4611 Assignment 3: Earthquake + */ + +#include <sstream> +#include "earthquake.h" + + +Earthquake::Earthquake() { +} + +Earthquake::Earthquake(std::string s) { + line = s; +} + +Date Earthquake::date() { + int year = ParseInt(line.substr(12,4)); + int month = ParseInt(line.substr(17,2)); + int day = ParseInt(line.substr(20,2)); + int hour = ParseInt(line.substr(24,2)); + int minute = ParseInt(line.substr(27,2)); + double second = ParseFloat(line.substr(30,5)); + + return Date(month, day, year, hour, minute, second); +} + +double Earthquake::longitude() { + return ParseFloat(line.substr(44,8)); +} + +double Earthquake::latitude() { + return ParseFloat(line.substr(37,7)); +} + +double Earthquake::magnitude() { + return ParseFloat(line.substr(66,4)); +} + +double Earthquake::ParseFloat(std::string s) { + std::stringstream ss(s); + double f; + ss >> f; + return f; +} + +int Earthquake::ParseInt(std::string s) { + std::stringstream ss(s); + int i; + ss >> i; + return i; +}
\ No newline at end of file |