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
30 changes: 13 additions & 17 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<?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">
<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="output" path="build/classes"/>
</classpath>
<?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">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
3 changes: 0 additions & 3 deletions build/classes/.gitignore

This file was deleted.

Binary file not shown.
Binary file added build/classes/service/PersonalityCalculator.class
Binary file not shown.
Binary file not shown.
11 changes: 8 additions & 3 deletions src/controller/PersonalityViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.PersonalityCalculator;


@WebServlet(urlPatterns= {"/personality"})
public class PersonalityViewController extends HttpServlet {
private static final long serialVersionUID = 1L;


//Progression 4

// pc.findYourBrainType(options);

public PersonalityViewController() {
super();

Expand All @@ -34,7 +39,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)

System.out.println(options);

/*
PersonalityCalculator message = new PersonalityCalculator();

request.setAttribute("message", message);

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

}*/
}
}
}

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

//Progression 1
public class PersonalityCalculator{

// //Progression 2
public String findYourBrainType(String string) {
// //String options = "5,2,3,1,4,3,2,1,5,4,3,2,1,5,4,3,2,1,2,2";
// //Split function delimiter - ','
//
int ansInInt[]=findAnswers(string);
int A = ansInInt[0]+ansInInt[1]+ansInInt[2]+ansInInt[3]+ansInInt[4]+ansInInt[7]+ansInInt[9]+ansInInt[10]+ansInInt[11]+ansInInt[13]+ansInInt[17]+ansInInt[19];
int B = ansInInt[3]+ansInInt[5]+ansInInt[6]+ansInInt[8]+ansInInt[12]+ansInInt[14]+ansInInt[15]+ansInInt[16]+ansInInt[18];
int x = 66 - A - B;
// return options;
if(x>=20 && x<=55)
return "Left-brained";
else if (x >= 56 && x<=64)
return "No clear preference";
else if (x>=65 && x<=100)
return "Right-brained";
else
return "#";
}
// //Progression 3
public static int[] findAnswers(String options) {
String splitAns[] = options.split(",");
int[] ansInInt = new int[splitAns.length];
for(int i =0; i< splitAns.length;i++) {
ansInInt[i] = Integer.parseInt(splitAns[i]);
}
return ansInInt;
}

}



/*Range Results:
20-55 Left-brained
56-64 No clear preference
65-100 Right-brained
*/
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();
}
}
}*/
}