summaryrefslogtreecommitdiffstats
path: root/dev/a3-earthquake/earthquake.cc
diff options
context:
space:
mode:
authorunknown <paulx161@umn.edu>2021-02-17 13:53:18 -0600
committerunknown <paulx161@umn.edu>2021-02-17 13:53:18 -0600
commitb302ad0465573fd77fa50d5ed261289c29080b90 (patch)
tree28ef9128beff73e81a1c04d199283fb0e4ec7c8d /dev/a3-earthquake/earthquake.cc
parentAdded example projects from lecture (diff)
downloadcsci4611-b302ad0465573fd77fa50d5ed261289c29080b90.tar
csci4611-b302ad0465573fd77fa50d5ed261289c29080b90.tar.gz
csci4611-b302ad0465573fd77fa50d5ed261289c29080b90.tar.bz2
csci4611-b302ad0465573fd77fa50d5ed261289c29080b90.tar.lz
csci4611-b302ad0465573fd77fa50d5ed261289c29080b90.tar.xz
csci4611-b302ad0465573fd77fa50d5ed261289c29080b90.tar.zst
csci4611-b302ad0465573fd77fa50d5ed261289c29080b90.zip
Added Assignment 3 worksheet and code
Diffstat (limited to '')
-rw-r--r--dev/a3-earthquake/earthquake.cc50
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