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/
9 changes: 6 additions & 3 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 @@ -34,8 +36,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)

System.out.println(options);

/*

PersonalityCalculator pc=new PersonalityCalculator();

String message=pc.findYourBrainType(options);
request.setAttribute("message", message);

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

}*/
}
}
}

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

public class PersonalityCalculator
{

public String findYourBrainType(String options)
{

int newarr[]=findAnswers(options);
int a=(newarr[0]+newarr[1]+newarr[2]+newarr[4]+newarr[7]+newarr[9]+newarr[10]+newarr[11]+newarr[13]+newarr[17]+newarr[19]);

int b=newarr[3]+newarr[5]+newarr[6]+newarr[8]+newarr[12]+newarr[14]+newarr[15]+newarr[16]+newarr[18];
int x=66-a+b;

if(20<=x && x<=55) {
return "leftbrained";
}else if(56<=x && x<=64)
{
return "No clear preference";
}else if(65<=x && x<=100)
{
return "rightbrained";
}else
{
return "wrong !!! ";
}

}

public int[] findAnswers(String options ) {

String arr[]= options.split(",");
int size=arr.length;
int newarr []=new int[size];
for(int i=0;i<arr.length;i++)
{
newarr[i]=Integer.parseInt(arr[i]);
}


return newarr;

}
}
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();
}
}
}*/
}