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
deleted file mode 100644
index 4e7e508..0000000
--- a/build/classes/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/controller/
diff --git a/build/classes/controller/FlamesCheck.class b/build/classes/controller/FlamesCheck.class
index fe7152f..47d5f20 100644
Binary files a/build/classes/controller/FlamesCheck.class and b/build/classes/controller/FlamesCheck.class differ
diff --git a/build/classes/service/FlamesCheckService.class b/build/classes/service/FlamesCheckService.class
new file mode 100644
index 0000000..de46fa4
Binary files /dev/null and b/build/classes/service/FlamesCheckService.class differ
diff --git a/build/classes/testing/TestFlamesCheckService.class b/build/classes/testing/TestFlamesCheckService.class
new file mode 100644
index 0000000..45bcb27
Binary files /dev/null and b/build/classes/testing/TestFlamesCheckService.class differ
diff --git a/src/controller/FlamesCheck.java b/src/controller/FlamesCheck.java
index b9b9a0b..184b5b2 100644
--- a/src/controller/FlamesCheck.java
+++ b/src/controller/FlamesCheck.java
@@ -4,6 +4,7 @@
1.Do not modify the existing code at any point or you will not get output.
2. Uncomment the code inside the doPost method given in this class to run and see the output
*/
+import service.FlamesCheckService;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
@@ -33,35 +34,33 @@ 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);
- *
- * }
- */
+ //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);
+
+ }
}
}
diff --git a/src/service/FlamesCheckService.java b/src/service/FlamesCheckService.java
index a8c006a..c3d325c 100644
--- a/src/service/FlamesCheckService.java
+++ b/src/service/FlamesCheckService.java
@@ -7,3 +7,74 @@
// 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){
+ if(name1==null||name2==null)
+ return 'a';
+ System.out.println("Your name is "+name1+"\n"+"Your Partner name is "+name2);
+ name1.toLowerCase();
+ name2.toLowerCase();
+ char flames[]= {'f','l','a','m','e','s'};
+ char name1arr[]=name1.toCharArray();
+ char name2arr[]=name2.toCharArray();
+ int count=name1.length()+name2.length();
+ int flamesLength=6,index=0;
+ for(index=0;index=1)
+ {
+ int currentCount=count;
+ while(currentCount>0)
+ {
+ index=(index+1)%flamesLength;
+ currentCount--;
+ }
+ if(index==0)
+ index=flamesLength-1;
+ else
+ index--;
+ for(int index2=index;index2