aboutsummaryrefslogtreecommitdiff
path: root/week11/Exercise04/Street.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'week11/Exercise04/Street.cpp')
-rw-r--r--week11/Exercise04/Street.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/week11/Exercise04/Street.cpp b/week11/Exercise04/Street.cpp
new file mode 100644
index 0000000..8cc6905
--- /dev/null
+++ b/week11/Exercise04/Street.cpp
@@ -0,0 +1,17 @@
+#include "Street.h"
+
+unsigned numberLength(unsigned num) {
+ if (num == 0) return 1;
+
+ unsigned len = 0;
+ while (num != 0) {
+ len++;
+ num /= 10;
+ }
+
+ return len;
+}
+
+unsigned Street::Length() {
+ return String::Length() + numberLength(streetNumber);
+}