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
7 changes: 2 additions & 5 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
<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">
<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">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="C:/Users/USER/Downloads/javax.servlet-3.0.jar~/javax.servlet-3.0.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
1 change: 0 additions & 1 deletion build/classes/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/service/
/controller/
/testing/
Binary file not shown.
10 changes: 6 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,11 +35,11 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
String options=request.getParameter("selectedOptions");

System.out.println(options);
/*
PersonalityCalculator person = new PersonalityCalculator();
String message = person.findYourBrainType(options);

request.setAttribute("message", message);

System.out.println(message);
if(message!=null)
{
if(message.equals("rightbrained")) {
Expand All @@ -53,7 +55,7 @@ else if(message.equals("leftbrained")) {
rd.forward(request, response);
}

}*/
}
}
}

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

public class PersonalityCalculator
{
public String findYourBrainType(String inp)
{
System.out.println(inp);
int x = findAnswers(inp);
String str ="";
if(x>=20 && x <= 55)
str = "leftbrained";
if(x>=56 && x <=64)
str = "No clear preference";
if(x>=65 && x<=100)
str = "rightbrained";
System.out.println(str);
return str;
}
public int findAnswers(String inp)
{
String[] values = inp.split(",");
int size = values.length;
System.out.println(size);
int [] arr = new int [size];
for(int i=0; i<size; i++) {
arr[i] = Integer.parseInt(values[i]);
System.out.println(arr[i]);
}
int a = (arr[0]+arr[1]+arr[2]+arr[4]+arr[7]+arr[9]+arr[10]+arr[11]+arr[13]+arr[17]+arr[19]);
System.out.println(a);
int b = arr[3]+arr[5]+arr[6]+arr[8]+arr[12]+arr[14]+arr[15]+arr[16]+arr[18];
System.out.println(b);
int x = 66 - a + b;
return x;
}
}
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
// 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();
}
}
}*/
}