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
8 changes: 4 additions & 4 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v9.0">
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v9.0">
<attributes>
<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">
<classpathentry exported="true" 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>
Expand Down
2 changes: 0 additions & 2 deletions build/classes/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/service/
/controller/
/testing/
Binary file not shown.
Binary file not shown.
8 changes: 4 additions & 4 deletions src/controller/PersonalityViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.PersonalityCalculator;

@WebServlet(urlPatterns= {"/personality"})
public class PersonalityViewController extends HttpServlet {
Expand All @@ -31,10 +31,10 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)


String options=request.getParameter("selectedOptions");

PersonalityCalculator personality=new PersonalityCalculator();
System.out.println(options);

/*
String message=personality.findYourBrainType(options);

request.setAttribute("message", message);

Expand All @@ -53,7 +53,7 @@ else if(message.equals("leftbrained")) {
rd.forward(request, response);
}

}*/
}
}
}

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

public class PersonalityCalculator{
public String findYourBrainType(String options) {
int[] answers=findAnswers(options);

int A=0, B=0;
A=answers[0]+answers[1]+answers[2]+answers[4]+answers[7]+answers[9]+answers[10]+answers[11]+answers[13]+answers[17]+answers[19];
B=answers[3]+answers[5]+answers[6]+answers[8]+answers[12]+answers[14]+answers[15]+answers[16]+answers[18];
int braintype=66-(A-B);
if(braintype>=20 && braintype<=55)
return "leftbrained";
else if(braintype>=56 && braintype<=64)
return "noclearpreference";
else
return "rightbrained";


}

public int[] findAnswers(String options) {
String[] selectedAnswer=options.split(",");
int[] answer=new int[selectedAnswer.length];
for(int i=0;i<selectedAnswer.length;i++) {
answer[i]=Integer.parseInt(selectedAnswer[i]);
}
return answer;
}



}
4 changes: 2 additions & 2 deletions src/testing/TestPersonalityCalculator.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package testing;
/* Uncomment the below code to test your application

import static org.junit.Assert.assertEquals;

Expand Down Expand Up @@ -28,4 +28,4 @@ public void testFindYourBrainTypeMethod() {
e.printStackTrace();
}
}
}*/
}