diff --git a/.classpath b/.classpath
index 2846539..20c137d 100644
--- a/.classpath
+++ b/.classpath
@@ -8,10 +8,6 @@
-
-
-
-
-
+
diff --git a/build/classes/.gitignore b/build/classes/.gitignore
index 4e7e508..764c814 100644
--- a/build/classes/.gitignore
+++ b/build/classes/.gitignore
@@ -1 +1,3 @@
/controller/
+/testing/
+/service/
diff --git a/build/classes/controller/FlamesCheck.class b/build/classes/controller/FlamesCheck.class
index fe7152f..67b9ec4 100644
Binary files a/build/classes/controller/FlamesCheck.class and b/build/classes/controller/FlamesCheck.class differ
diff --git a/src/controller/FlamesCheck.java b/src/controller/FlamesCheck.java
index b9b9a0b..e6022a1 100644
--- a/src/controller/FlamesCheck.java
+++ b/src/controller/FlamesCheck.java
@@ -5,6 +5,7 @@
2. Uncomment the code inside the doPost method given in this class to run and see the output
*/
import java.io.IOException;
+import service.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
@@ -33,35 +34,34 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- /*
- * Uncomment the below code to test your output
- * String name1 = request.getParameter("your");
- * String name2 = request.getParameter("crush");
- *
- * FlamesCheckService fcs = new FlamesCheckService();
- *
- * char k = fcs.findFlames(name1,name2);
- *
- * if (k == 'f') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher("/WEB-INF/views/friends.jsp"
- * ); rd.forward(request, response);
- *
- * } else if (k == 'l') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher("/WEB-INF/views/lovers.jsp")
- * ; rd.forward(request, response);
- *
- * } else if (k == 'a') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher(
- * "/WEB-INF/views/affection.jsp"); rd.forward(request, response);
- *
- * } else if (k == 'm') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher(
- * "/WEB-INF/views/marriage.jsp"); rd.forward(request, response);
- *
- * } else if (k == 'e') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher("/WEB-INF/views/enemies.jsp"
- * ); rd.forward(request, response);
- *
- * } else if (k == 's') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher(
- * "/WEB-INF/views/siblings.jsp"); rd.forward(request, response);
- *
- * }
- */
+
+ String name1 = request.getParameter("your");
+ String name2 = request.getParameter("crush");
+
+ FlamesCheckService fcs = new FlamesCheckService();
+
+ char k = fcs.findFlames(name1,name2);
+
+ if (k == 'f') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher("/WEB-INF/views/friends.jsp"
+ ); rd.forward(request, response);
+
+ } else if (k == 'l') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher("/WEB-INF/views/lovers.jsp")
+ ; rd.forward(request, response);
+
+ } else if (k == 'a') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher(
+ "/WEB-INF/views/affection.jsp"); rd.forward(request, response);
+
+ } else if (k == 'm') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher(
+ "/WEB-INF/views/marriage.jsp"); rd.forward(request, response);
+
+ } else if (k == 'e') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher("/WEB-INF/views/enemies.jsp"
+ ); rd.forward(request, response);
+
+ } else if (k == 's') { RequestDispatcher rd=this.getServletContext().getRequestDispatcher(
+ "/WEB-INF/views/siblings.jsp"); rd.forward(request, response);
+
+ }
+
}
}
diff --git a/src/service/FlamesCheckService.java b/src/service/FlamesCheckService.java
index a8c006a..70456bb 100644
--- a/src/service/FlamesCheckService.java
+++ b/src/service/FlamesCheckService.java
@@ -7,3 +7,87 @@
// You must return only the following values ['f','l','a','m','e','s']
// change the return value at the end of the method corresponding to your return value
+public class FlamesCheckService{
+
+ public char findFlames(String name1, String name2) {
+ int wordLength = cutChar(name1, name2);
+ //System.out.println("word length: " + wordLength);
+
+ char[] flames = {'f','l','a','m','e','s'};
+ int count = 0;
+ while(true) {
+
+ for(int i =0; i= arr.length) {
+ return arr;
+ }
+
+ char[] anotherArray = new char[arr.length - 1];
+
+ for (int i = 0, k = 0; i < arr.length; i++) {
+
+ if (i == index) {
+ continue;
+ }
+
+ anotherArray[k++] = arr[i];
+ }
+
+ return anotherArray;
+ }
+
+ public static char[] convertCharArray(String str)
+ {
+ char[] ch = new char[str.length()];
+
+ for (int i = 0; i < str.length(); i++) {
+ ch[i] = str.charAt(i);
+ }
+
+ return ch;
+ }
+}
diff --git a/src/testing/TestFlamesCheckService.java b/src/testing/TestFlamesCheckService.java
index f3b45fe..22c64dc 100644
--- a/src/testing/TestFlamesCheckService.java
+++ b/src/testing/TestFlamesCheckService.java
@@ -8,30 +8,30 @@
public class TestFlamesCheckService {
FlamesCheckService fcs = new FlamesCheckService();
@Test
-// public void testFindFlamesMethod() {
-// String name1 = "Alex";
-// String name2 = "Joylin";
-// char temp = 'a';
-// assertEquals(temp,fcs.findFlames(name1, name2));
-// name1 = "Steffe";
-// name2 = "Bobby";
-// temp = 'm';
-// assertEquals(temp,fcs.findFlames(name1, name2));
-// name1 = "John";
-// name2 = "Jully";
-// temp = 'e';
-// assertEquals(temp,fcs.findFlames(name1, name2));
-// name1 = "George";
-// name2 = "Neythiri";
-// temp = 'l';
-// assertEquals(temp,fcs.findFlames(name1, name2));
-// try {
-// fcs.findFlames(null, null);
-// fcs.findFlames("AAA", null);
-// fcs.findFlames(null, "BBB");
-// }
-// catch(Exception e) {
-// e.printStackTrace();
-// }
-// }
+ public void testFindFlamesMethod() {
+ String name1 = "Alex";
+ String name2 = "Joylin";
+ char temp = 'a';
+ assertEquals(temp,fcs.findFlames(name1, name2));
+ name1 = "Steffe";
+ name2 = "Bobby";
+ temp = 'm';
+ assertEquals(temp,fcs.findFlames(name1, name2));
+ name1 = "John";
+ name2 = "Jully";
+ temp = 'e';
+ assertEquals(temp,fcs.findFlames(name1, name2));
+ name1 = "George";
+ name2 = "Neythiri";
+ temp = 'l';
+ assertEquals(temp,fcs.findFlames(name1, name2));
+ try {
+ fcs.findFlames(null, null);
+ fcs.findFlames("AAA", null);
+ fcs.findFlames(null, "BBB");
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
}