Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.8.0_241">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
3 changes: 1 addition & 2 deletions build/classes/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/service/
/controller/
/testing/
/service/
11 changes: 7 additions & 4 deletions src/controller/PersonalityViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.PersonalityCalculator;


@WebServlet(urlPatterns= {"/personality"})
public class PersonalityViewController extends HttpServlet {
Expand All @@ -33,8 +35,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
String options=request.getParameter("selectedOptions");

System.out.println(options);

/*
PersonalityCalculator pc = new PersonalityCalculator();
String message = pc.findYourBrainType(options);


request.setAttribute("message", message);

Expand All @@ -52,8 +55,8 @@ else if(message.equals("leftbrained")) {
RequestDispatcher rd=this.getServletContext().getRequestDispatcher("/WEB-INF/views/neutralView.jsp");
rd.forward(request, response);
}
}*/

}
}
}

Expand Down
32 changes: 32 additions & 0 deletions src/service/PersonalityCalculator.java
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
package service;

public class PersonalityCalculator{

public String findYourBrainType(String options){
int array[] = findAnswers(options);
int a=array[0]+array[1]+array[2]+array[4]+array[7]+array[9]+array[10]+array[11]+array[13]+array[17]+array[19];
int b=array[3]+array[5]+array[6]+array[12]+array[14]+array[15]+array[16]+array[18];
int x=66-a+b;
System.out.println("Your total score "+x);
if((x>=22)&&(x<=55))
return "Left-brained ";
if((x>=56)&&(x<=64))
return "No clear preference ";
if((x>=65)&&(x<=100))
return "Right-brained";
return "false";
}

public int[] findAnswers(String options) {
String c[]=options.split(",");
int value=c.length;
int array[]=new int[value];
int i=0;
for(String s:c) //for-each loop
{
array[i]=Integer.parseInt(s);
i++;
}

return array;
}
}