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>
2 changes: 1 addition & 1 deletion build/classes/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/service/
/controller/
/service/
/testing/
11 changes: 8 additions & 3 deletions src/controller/PersonalityViewController.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package controller;
package controller;

import java.io.IOException;

Expand All @@ -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 @@ -31,10 +33,13 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)


String options=request.getParameter("selectedOptions");
PersonalityCalculator personality = new PersonalityCalculator();

String message = personality.findYourBrainType(options);

System.out.println(options);

/*


request.setAttribute("message", message);

Expand All @@ -53,7 +58,7 @@ else if(message.equals("leftbrained")) {
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[] answers = findPersonality(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[7]+answers[8]+answers[12]+answers[14]+answers[15]+answers[16]+answers[18];
int x = 66-A+B;

if(x>=22 && x<=55)
return "leftbrained";
else if(x>=56 && x<=64)
return "noclearpreference";
else
return "rightbrained";
}

public int[] findPersonality(String options) {

String[] choiceAnswer = options.split(",");
int[] answer = new int[choiceAnswer.length];
for(int i=0;i<choiceAnswer.length;i++) {

answer[i] = Integer.parseInt(choiceAnswer[i]);

}
return answer;
}

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

import static org.junit.Assert.assertEquals;

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