From 70e42788c258fce143a7d5dd7c2dceb5b7a51777 Mon Sep 17 00:00:00 2001
From: Liam Coddington <45324128+liamcoddington@users.noreply.github.com>
Date: Thu, 20 May 2021 19:20:34 -0500
Subject: [PATCH 1/5] Changes
---
.idea/compiler.xml | 16 ++++++
.idea/encodings.xml | 6 +++
.idea/jarRepositories.xml | 20 +++++++
.../Maven__joda_time_joda_time_2_9_7.xml | 13 +++++
..._org_apiguardian_apiguardian_api_1_0_0.xml | 13 +++++
..._junit_jupiter_junit_jupiter_api_5_4_2.xml | 13 +++++
...nit_jupiter_junit_jupiter_engine_5_4_2.xml | 13 +++++
..._platform_junit_platform_commons_1_4_2.xml | 13 +++++
...t_platform_junit_platform_engine_1_4_2.xml | 13 +++++
...Maven__org_opentest4j_opentest4j_1_1_1.xml | 13 +++++
.idea/misc.xml | 11 ++++
.idea/modules.xml | 8 +++
.idea/vcs.xml | 6 +++
.idea/workspace.xml | 54 +++++++++++++++++++
java-interview.iml | 21 ++++++++
src/main/java/com/github/archarithms/App.java | 43 ++++++++++++---
.../archarithms/test/DateStringTests.java | 11 +++-
.../archarithms/test/TitleCaseTests.java | 29 ++++++++--
18 files changed, 304 insertions(+), 12 deletions(-)
create mode 100644 .idea/compiler.xml
create mode 100644 .idea/encodings.xml
create mode 100644 .idea/jarRepositories.xml
create mode 100644 .idea/libraries/Maven__joda_time_joda_time_2_9_7.xml
create mode 100644 .idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml
create mode 100644 .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml
create mode 100644 .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml
create mode 100644 .idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml
create mode 100644 .idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml
create mode 100644 .idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 .idea/workspace.xml
create mode 100644 java-interview.iml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..39d929e
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..63e9001
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__joda_time_joda_time_2_9_7.xml b/.idea/libraries/Maven__joda_time_joda_time_2_9_7.xml
new file mode 100644
index 0000000..984d50b
--- /dev/null
+++ b/.idea/libraries/Maven__joda_time_joda_time_2_9_7.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml
new file mode 100644
index 0000000..a82457d
--- /dev/null
+++ b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml
new file mode 100644
index 0000000..5a695a5
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml
new file mode 100644
index 0000000..688205a
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml
new file mode 100644
index 0000000..1507a25
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml
new file mode 100644
index 0000000..080af65
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml b/.idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml
new file mode 100644
index 0000000..70277df
--- /dev/null
+++ b/.idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..25daa30
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..958c2f6
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..3c21e88
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1621546576400
+
+
+ 1621546576400
+
+
+
+
\ No newline at end of file
diff --git a/java-interview.iml b/java-interview.iml
new file mode 100644
index 0000000..0031144
--- /dev/null
+++ b/java-interview.iml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/github/archarithms/App.java b/src/main/java/com/github/archarithms/App.java
index dcb6723..550f5c9 100644
--- a/src/main/java/com/github/archarithms/App.java
+++ b/src/main/java/com/github/archarithms/App.java
@@ -1,15 +1,46 @@
package com.github.archarithms;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
public class App
{
- public static String convertToTitleCase(final String inpStr)
- {
- return inpStr;
+ public static String convertToTitleCase(final String inpStr) throws Exception {
+ if (inpStr == null) {
+ throw new Exception();
+ }
+ StringBuilder sb = new StringBuilder();
+ // Split up the string and remove all of the garbage characters
+ String[] splitInput = inpStr.split("]|-|_|\\[|/");
+ for (int i = 0; i < splitInput.length; i++) {
+ // Set the entire string to lowercase
+ String s = splitInput[i].toLowerCase();
+ // check to see if the string contains anything
+ if (s.length() > 0) {
+ // Set the first letter to Uppercase if possible
+ String first = s.substring(0, 1).toUpperCase();
+ String temp = s.substring(1);
+ // Concat the 2 strings and append it to the StringBuilder
+ sb.append(first.concat(temp));
+ }
+ // Append a space to the StringBuilder this isn't the last string
+ if (i < splitInput.length - 1) {
+ sb.append(" ");
+ }
+ }
+ return sb.toString();
}
- public static String convertUnixToDateString(final Long inpUnixSeconds)
- {
- return String.valueOf(inpUnixSeconds);
+ public static String convertUnixToDateString(final Long inpUnixSeconds) throws Exception {
+ if (inpUnixSeconds == null) {
+ throw new Exception();
+ }
+ // Convert to milliseconds
+ Long millis = inpUnixSeconds * 1000;
+ // Using DateFormat with a Date to make get the correct format
+ Date date = new Date(millis);
+ DateFormat format = new SimpleDateFormat("MMMMMMMMM d, y");
+ return format.format(date);
}
}
diff --git a/src/test/java/com/github/archarithms/test/DateStringTests.java b/src/test/java/com/github/archarithms/test/DateStringTests.java
index 04e9943..1f45eed 100644
--- a/src/test/java/com/github/archarithms/test/DateStringTests.java
+++ b/src/test/java/com/github/archarithms/test/DateStringTests.java
@@ -21,7 +21,7 @@ public class DateStringTests
* Test the testConvertUnixToDateString method
*/
@Test
- public void testConvertUnixToDateString() {
+ public void testConvertUnixToDateString() throws Exception {
String testStr = "July 4, 2017";
assertTrue(testStr.equals(App.convertUnixToDateString(1499144400L)));
}
@@ -33,4 +33,13 @@ public void testConvertUnixToDateString() {
public void testNullCase() {
assertThrows(Exception.class, () -> App.convertUnixToDateString(null));
}
+
+ /**
+ * Test the testMyBirthday method
+ */
+ @Test
+ public void testMyBirthday() throws Exception {
+ String testStr = "August 14, 1998";
+ assertTrue(testStr.equals(App.convertUnixToDateString(903114000L)));
+ }
}
diff --git a/src/test/java/com/github/archarithms/test/TitleCaseTests.java b/src/test/java/com/github/archarithms/test/TitleCaseTests.java
index bd3bb2d..674b2af 100644
--- a/src/test/java/com/github/archarithms/test/TitleCaseTests.java
+++ b/src/test/java/com/github/archarithms/test/TitleCaseTests.java
@@ -1,11 +1,13 @@
package com.github.archarithms.test;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
import org.junit.jupiter.api.Test;
import com.github.archarithms.App;
+import java.text.ParseException;
+
+import static org.junit.jupiter.api.Assertions.*;
+
/**
* TitleCaseTests unit tests for simple App.
*/
@@ -20,7 +22,7 @@ public class TitleCaseTests
* Test the testConvertToTitleCase method
*/
@Test
- public void testConvertToTitleCase() {
+ public void testConvertToTitleCase() throws Exception {
String testStr = "Title Case";
assertTrue(testStr.equals(App.convertToTitleCase("TITLE_CASE")));
}
@@ -29,7 +31,7 @@ public void testConvertToTitleCase() {
* Test the testNumbers method
*/
@Test
- public void testNumbers() {
+ public void testNumbers() throws Exception {
String testStr = "Number 3";
assertTrue(testStr.equals(App.convertToTitleCase("NUMBER_3")));
}
@@ -38,8 +40,25 @@ public void testNumbers() {
* Test the testOtherChars method
*/
@Test
- public void testOtherChars() {
+ public void testOtherChars() throws Exception {
String testStr = "Truth Track";
assertTrue(testStr.equals(App.convertToTitleCase("TRUTH-TRACK")));
}
+
+ /**
+ * Test the testMultipleChars method
+ */
+ @Test
+ public void testMultipleChars() throws Exception {
+ String testStr = "Case Three Extra Chars";
+ assertTrue(testStr.equals(App.convertToTitleCase("CASE-THREE_extra[chars]///")));
+ }
+
+ /**
+ * Test the testNullString method
+ */
+ @Test
+ public void testNullString() {
+ assertThrows(Exception.class, () -> App.convertToTitleCase(null));
+ }
}
From 1e39d84f2f55a1434456870311bde8b712bee3a7 Mon Sep 17 00:00:00 2001
From: Liam Coddington <45324128+liamcoddington@users.noreply.github.com>
Date: Thu, 20 May 2021 19:27:47 -0500
Subject: [PATCH 2/5] Meaningless ide changes
---
.idea/workspace.xml | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 3c21e88..3c36350 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,7 @@
-
-
-
-
-
+
From d0e3a4d49fb6eae054fc7e223cc70a41e45fe506 Mon Sep 17 00:00:00 2001
From: Liam Coddington <45324128+liamcoddington@users.noreply.github.com>
Date: Thu, 20 May 2021 19:27:53 -0500
Subject: [PATCH 3/5] Revert "Meaningless ide changes"
This reverts commit 1e39d84f2f55a1434456870311bde8b712bee3a7.
---
.idea/workspace.xml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 3c36350..3c21e88 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,11 @@
-
+
+
+
+
+
From 08d9d8e47645c4ca2f1b52bcdfb677ad706f6f06 Mon Sep 17 00:00:00 2001
From: Liam Coddington <45324128+liamcoddington@users.noreply.github.com>
Date: Thu, 20 May 2021 19:27:57 -0500
Subject: [PATCH 4/5] Revert "Changes"
This reverts commit 70e42788c258fce143a7d5dd7c2dceb5b7a51777.
---
.idea/compiler.xml | 16 ------
.idea/encodings.xml | 6 ---
.idea/jarRepositories.xml | 20 -------
.../Maven__joda_time_joda_time_2_9_7.xml | 13 -----
..._org_apiguardian_apiguardian_api_1_0_0.xml | 13 -----
..._junit_jupiter_junit_jupiter_api_5_4_2.xml | 13 -----
...nit_jupiter_junit_jupiter_engine_5_4_2.xml | 13 -----
..._platform_junit_platform_commons_1_4_2.xml | 13 -----
...t_platform_junit_platform_engine_1_4_2.xml | 13 -----
...Maven__org_opentest4j_opentest4j_1_1_1.xml | 13 -----
.idea/misc.xml | 11 ----
.idea/modules.xml | 8 ---
.idea/vcs.xml | 6 ---
.idea/workspace.xml | 54 -------------------
java-interview.iml | 21 --------
src/main/java/com/github/archarithms/App.java | 43 +++------------
.../archarithms/test/DateStringTests.java | 11 +---
.../archarithms/test/TitleCaseTests.java | 29 ++--------
18 files changed, 12 insertions(+), 304 deletions(-)
delete mode 100644 .idea/compiler.xml
delete mode 100644 .idea/encodings.xml
delete mode 100644 .idea/jarRepositories.xml
delete mode 100644 .idea/libraries/Maven__joda_time_joda_time_2_9_7.xml
delete mode 100644 .idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml
delete mode 100644 .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml
delete mode 100644 .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml
delete mode 100644 .idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml
delete mode 100644 .idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml
delete mode 100644 .idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml
delete mode 100644 .idea/misc.xml
delete mode 100644 .idea/modules.xml
delete mode 100644 .idea/vcs.xml
delete mode 100644 .idea/workspace.xml
delete mode 100644 java-interview.iml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 39d929e..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index 63e9001..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
deleted file mode 100644
index 712ab9d..0000000
--- a/.idea/jarRepositories.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__joda_time_joda_time_2_9_7.xml b/.idea/libraries/Maven__joda_time_joda_time_2_9_7.xml
deleted file mode 100644
index 984d50b..0000000
--- a/.idea/libraries/Maven__joda_time_joda_time_2_9_7.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml
deleted file mode 100644
index a82457d..0000000
--- a/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml
deleted file mode 100644
index 5a695a5..0000000
--- a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml
deleted file mode 100644
index 688205a..0000000
--- a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml
deleted file mode 100644
index 1507a25..0000000
--- a/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml
deleted file mode 100644
index 080af65..0000000
--- a/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml b/.idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml
deleted file mode 100644
index 70277df..0000000
--- a/.idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 25daa30..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 958c2f6..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 3c21e88..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1621546576400
-
-
- 1621546576400
-
-
-
-
\ No newline at end of file
diff --git a/java-interview.iml b/java-interview.iml
deleted file mode 100644
index 0031144..0000000
--- a/java-interview.iml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/com/github/archarithms/App.java b/src/main/java/com/github/archarithms/App.java
index 550f5c9..dcb6723 100644
--- a/src/main/java/com/github/archarithms/App.java
+++ b/src/main/java/com/github/archarithms/App.java
@@ -1,46 +1,15 @@
package com.github.archarithms;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
public class App
{
- public static String convertToTitleCase(final String inpStr) throws Exception {
- if (inpStr == null) {
- throw new Exception();
- }
- StringBuilder sb = new StringBuilder();
- // Split up the string and remove all of the garbage characters
- String[] splitInput = inpStr.split("]|-|_|\\[|/");
- for (int i = 0; i < splitInput.length; i++) {
- // Set the entire string to lowercase
- String s = splitInput[i].toLowerCase();
- // check to see if the string contains anything
- if (s.length() > 0) {
- // Set the first letter to Uppercase if possible
- String first = s.substring(0, 1).toUpperCase();
- String temp = s.substring(1);
- // Concat the 2 strings and append it to the StringBuilder
- sb.append(first.concat(temp));
- }
- // Append a space to the StringBuilder this isn't the last string
- if (i < splitInput.length - 1) {
- sb.append(" ");
- }
- }
- return sb.toString();
+ public static String convertToTitleCase(final String inpStr)
+ {
+ return inpStr;
}
- public static String convertUnixToDateString(final Long inpUnixSeconds) throws Exception {
- if (inpUnixSeconds == null) {
- throw new Exception();
- }
- // Convert to milliseconds
- Long millis = inpUnixSeconds * 1000;
- // Using DateFormat with a Date to make get the correct format
- Date date = new Date(millis);
- DateFormat format = new SimpleDateFormat("MMMMMMMMM d, y");
- return format.format(date);
+ public static String convertUnixToDateString(final Long inpUnixSeconds)
+ {
+ return String.valueOf(inpUnixSeconds);
}
}
diff --git a/src/test/java/com/github/archarithms/test/DateStringTests.java b/src/test/java/com/github/archarithms/test/DateStringTests.java
index 1f45eed..04e9943 100644
--- a/src/test/java/com/github/archarithms/test/DateStringTests.java
+++ b/src/test/java/com/github/archarithms/test/DateStringTests.java
@@ -21,7 +21,7 @@ public class DateStringTests
* Test the testConvertUnixToDateString method
*/
@Test
- public void testConvertUnixToDateString() throws Exception {
+ public void testConvertUnixToDateString() {
String testStr = "July 4, 2017";
assertTrue(testStr.equals(App.convertUnixToDateString(1499144400L)));
}
@@ -33,13 +33,4 @@ public void testConvertUnixToDateString() throws Exception {
public void testNullCase() {
assertThrows(Exception.class, () -> App.convertUnixToDateString(null));
}
-
- /**
- * Test the testMyBirthday method
- */
- @Test
- public void testMyBirthday() throws Exception {
- String testStr = "August 14, 1998";
- assertTrue(testStr.equals(App.convertUnixToDateString(903114000L)));
- }
}
diff --git a/src/test/java/com/github/archarithms/test/TitleCaseTests.java b/src/test/java/com/github/archarithms/test/TitleCaseTests.java
index 674b2af..bd3bb2d 100644
--- a/src/test/java/com/github/archarithms/test/TitleCaseTests.java
+++ b/src/test/java/com/github/archarithms/test/TitleCaseTests.java
@@ -1,13 +1,11 @@
package com.github.archarithms.test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.junit.jupiter.api.Test;
import com.github.archarithms.App;
-import java.text.ParseException;
-
-import static org.junit.jupiter.api.Assertions.*;
-
/**
* TitleCaseTests unit tests for simple App.
*/
@@ -22,7 +20,7 @@ public class TitleCaseTests
* Test the testConvertToTitleCase method
*/
@Test
- public void testConvertToTitleCase() throws Exception {
+ public void testConvertToTitleCase() {
String testStr = "Title Case";
assertTrue(testStr.equals(App.convertToTitleCase("TITLE_CASE")));
}
@@ -31,7 +29,7 @@ public void testConvertToTitleCase() throws Exception {
* Test the testNumbers method
*/
@Test
- public void testNumbers() throws Exception {
+ public void testNumbers() {
String testStr = "Number 3";
assertTrue(testStr.equals(App.convertToTitleCase("NUMBER_3")));
}
@@ -40,25 +38,8 @@ public void testNumbers() throws Exception {
* Test the testOtherChars method
*/
@Test
- public void testOtherChars() throws Exception {
+ public void testOtherChars() {
String testStr = "Truth Track";
assertTrue(testStr.equals(App.convertToTitleCase("TRUTH-TRACK")));
}
-
- /**
- * Test the testMultipleChars method
- */
- @Test
- public void testMultipleChars() throws Exception {
- String testStr = "Case Three Extra Chars";
- assertTrue(testStr.equals(App.convertToTitleCase("CASE-THREE_extra[chars]///")));
- }
-
- /**
- * Test the testNullString method
- */
- @Test
- public void testNullString() {
- assertThrows(Exception.class, () -> App.convertToTitleCase(null));
- }
}
From 2f9ffab3031a94010de0c89f28b984a3867ce2bf Mon Sep 17 00:00:00 2001
From: Liam Coddington <45324128+liamcoddington@users.noreply.github.com>
Date: Thu, 20 May 2021 19:30:39 -0500
Subject: [PATCH 5/5] Code interview changes
I'm not sure what was happening with my Git client.
---
.idea/.gitignore | 3 ++
.idea/compiler.xml | 16 +++++++
.idea/encodings.xml | 6 +++
.idea/jarRepositories.xml | 20 +++++++++
.../Maven__joda_time_joda_time_2_9_7.xml | 13 ++++++
..._org_apiguardian_apiguardian_api_1_0_0.xml | 13 ++++++
..._junit_jupiter_junit_jupiter_api_5_4_2.xml | 13 ++++++
...nit_jupiter_junit_jupiter_engine_5_4_2.xml | 13 ++++++
..._platform_junit_platform_commons_1_4_2.xml | 13 ++++++
...t_platform_junit_platform_engine_1_4_2.xml | 13 ++++++
...Maven__org_opentest4j_opentest4j_1_1_1.xml | 13 ++++++
.idea/misc.xml | 11 +++++
.idea/modules.xml | 8 ++++
.idea/vcs.xml | 6 +++
java-interview.iml | 21 +++++++++
src/main/java/com/github/archarithms/App.java | 43 ++++++++++++++++---
.../archarithms/test/DateStringTests.java | 11 ++++-
.../archarithms/test/TitleCaseTests.java | 29 ++++++++++---
18 files changed, 253 insertions(+), 12 deletions(-)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/compiler.xml
create mode 100644 .idea/encodings.xml
create mode 100644 .idea/jarRepositories.xml
create mode 100644 .idea/libraries/Maven__joda_time_joda_time_2_9_7.xml
create mode 100644 .idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml
create mode 100644 .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml
create mode 100644 .idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml
create mode 100644 .idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml
create mode 100644 .idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml
create mode 100644 .idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 java-interview.iml
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..39d929e
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..63e9001
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__joda_time_joda_time_2_9_7.xml b/.idea/libraries/Maven__joda_time_joda_time_2_9_7.xml
new file mode 100644
index 0000000..984d50b
--- /dev/null
+++ b/.idea/libraries/Maven__joda_time_joda_time_2_9_7.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml
new file mode 100644
index 0000000..a82457d
--- /dev/null
+++ b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml
new file mode 100644
index 0000000..5a695a5
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_4_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml
new file mode 100644
index 0000000..688205a
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_4_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml
new file mode 100644
index 0000000..1507a25
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_4_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml
new file mode 100644
index 0000000..080af65
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_4_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml b/.idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml
new file mode 100644
index 0000000..70277df
--- /dev/null
+++ b/.idea/libraries/Maven__org_opentest4j_opentest4j_1_1_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..25daa30
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..958c2f6
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/java-interview.iml b/java-interview.iml
new file mode 100644
index 0000000..0031144
--- /dev/null
+++ b/java-interview.iml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/github/archarithms/App.java b/src/main/java/com/github/archarithms/App.java
index dcb6723..550f5c9 100644
--- a/src/main/java/com/github/archarithms/App.java
+++ b/src/main/java/com/github/archarithms/App.java
@@ -1,15 +1,46 @@
package com.github.archarithms;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
public class App
{
- public static String convertToTitleCase(final String inpStr)
- {
- return inpStr;
+ public static String convertToTitleCase(final String inpStr) throws Exception {
+ if (inpStr == null) {
+ throw new Exception();
+ }
+ StringBuilder sb = new StringBuilder();
+ // Split up the string and remove all of the garbage characters
+ String[] splitInput = inpStr.split("]|-|_|\\[|/");
+ for (int i = 0; i < splitInput.length; i++) {
+ // Set the entire string to lowercase
+ String s = splitInput[i].toLowerCase();
+ // check to see if the string contains anything
+ if (s.length() > 0) {
+ // Set the first letter to Uppercase if possible
+ String first = s.substring(0, 1).toUpperCase();
+ String temp = s.substring(1);
+ // Concat the 2 strings and append it to the StringBuilder
+ sb.append(first.concat(temp));
+ }
+ // Append a space to the StringBuilder this isn't the last string
+ if (i < splitInput.length - 1) {
+ sb.append(" ");
+ }
+ }
+ return sb.toString();
}
- public static String convertUnixToDateString(final Long inpUnixSeconds)
- {
- return String.valueOf(inpUnixSeconds);
+ public static String convertUnixToDateString(final Long inpUnixSeconds) throws Exception {
+ if (inpUnixSeconds == null) {
+ throw new Exception();
+ }
+ // Convert to milliseconds
+ Long millis = inpUnixSeconds * 1000;
+ // Using DateFormat with a Date to make get the correct format
+ Date date = new Date(millis);
+ DateFormat format = new SimpleDateFormat("MMMMMMMMM d, y");
+ return format.format(date);
}
}
diff --git a/src/test/java/com/github/archarithms/test/DateStringTests.java b/src/test/java/com/github/archarithms/test/DateStringTests.java
index 04e9943..1f45eed 100644
--- a/src/test/java/com/github/archarithms/test/DateStringTests.java
+++ b/src/test/java/com/github/archarithms/test/DateStringTests.java
@@ -21,7 +21,7 @@ public class DateStringTests
* Test the testConvertUnixToDateString method
*/
@Test
- public void testConvertUnixToDateString() {
+ public void testConvertUnixToDateString() throws Exception {
String testStr = "July 4, 2017";
assertTrue(testStr.equals(App.convertUnixToDateString(1499144400L)));
}
@@ -33,4 +33,13 @@ public void testConvertUnixToDateString() {
public void testNullCase() {
assertThrows(Exception.class, () -> App.convertUnixToDateString(null));
}
+
+ /**
+ * Test the testMyBirthday method
+ */
+ @Test
+ public void testMyBirthday() throws Exception {
+ String testStr = "August 14, 1998";
+ assertTrue(testStr.equals(App.convertUnixToDateString(903114000L)));
+ }
}
diff --git a/src/test/java/com/github/archarithms/test/TitleCaseTests.java b/src/test/java/com/github/archarithms/test/TitleCaseTests.java
index bd3bb2d..674b2af 100644
--- a/src/test/java/com/github/archarithms/test/TitleCaseTests.java
+++ b/src/test/java/com/github/archarithms/test/TitleCaseTests.java
@@ -1,11 +1,13 @@
package com.github.archarithms.test;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
import org.junit.jupiter.api.Test;
import com.github.archarithms.App;
+import java.text.ParseException;
+
+import static org.junit.jupiter.api.Assertions.*;
+
/**
* TitleCaseTests unit tests for simple App.
*/
@@ -20,7 +22,7 @@ public class TitleCaseTests
* Test the testConvertToTitleCase method
*/
@Test
- public void testConvertToTitleCase() {
+ public void testConvertToTitleCase() throws Exception {
String testStr = "Title Case";
assertTrue(testStr.equals(App.convertToTitleCase("TITLE_CASE")));
}
@@ -29,7 +31,7 @@ public void testConvertToTitleCase() {
* Test the testNumbers method
*/
@Test
- public void testNumbers() {
+ public void testNumbers() throws Exception {
String testStr = "Number 3";
assertTrue(testStr.equals(App.convertToTitleCase("NUMBER_3")));
}
@@ -38,8 +40,25 @@ public void testNumbers() {
* Test the testOtherChars method
*/
@Test
- public void testOtherChars() {
+ public void testOtherChars() throws Exception {
String testStr = "Truth Track";
assertTrue(testStr.equals(App.convertToTitleCase("TRUTH-TRACK")));
}
+
+ /**
+ * Test the testMultipleChars method
+ */
+ @Test
+ public void testMultipleChars() throws Exception {
+ String testStr = "Case Three Extra Chars";
+ assertTrue(testStr.equals(App.convertToTitleCase("CASE-THREE_extra[chars]///")));
+ }
+
+ /**
+ * Test the testNullString method
+ */
+ @Test
+ public void testNullString() {
+ assertThrows(Exception.class, () -> App.convertToTitleCase(null));
+ }
}