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
5 changes: 3 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
<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.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>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<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 @@
/testing/
/service/
/controller/
/testing/
18 changes: 12 additions & 6 deletions src/controller/PersonalityViewController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controller;

import java.io.IOException;
import service.PersonalityCalculator;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
Expand Down Expand Up @@ -33,8 +34,10 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
String options=request.getParameter("selectedOptions");

System.out.println(options);

/*

PersonalityCalculator obj=new PersonalityCalculator();

String message=obj.findYourBrainType(options);

request.setAttribute("message", message);

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

}*/
}
}


}
// public static void main(String[] args) {
// PersonalityCalculator obj=new PersonalityCalculator();
// String message = obj.findYourBrain(options);
// }

}
39 changes: 39 additions & 0 deletions src/service/PersonalityCalculator.java
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
package service;

public class PersonalityCalculator{
// String[] options = {"5","2","3","1","4","3","2","1","5","4","3","2","1","5","4","3","2","1","2","2"};
// int[] optionsInt=new int[options.length];

//FUNCTION findYourBrainType
public String findYourBrainType(String input)
{
System.out.println(input);
int x = findAnswers(input);
String result ="";
if(x>=20 && x <= 55)
result = "leftbrained";
if(x>=56 && x <=64)
result = "noclearpreference";
if(x>=65 && x<=100)
result = "rightbrained";
System.out.println(result);
return result;
}

//FUNCTION findAnswers
public int findAnswers(String input)
{
String[] values = input.split(",");
int size = values.length;
System.out.println(size);
int [] arrInt = new int [size];
for(int i=0; i<size; i++) {
arrInt[i] = Integer.parseInt(values[i]);
System.out.println(arrInt[i]);
}
int A = (arrInt[0]+arrInt[1]+arrInt[2]+arrInt[4]+arrInt[7]+arrInt[9]+arrInt[10]+arrInt[11]+arrInt[13]+arrInt[17]+arrInt[19]);
System.out.println(A);
int B = arrInt[3]+arrInt[5]+arrInt[6]+arrInt[8]+arrInt[12]+arrInt[14]+arrInt[15]+arrInt[16]+arrInt[18];
System.out.println(B);
int x = 66 - A + B;
return x;
}
}
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();
}
}
}*/
}