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
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/
8 changes: 6 additions & 2 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,7 +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);

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

}*/
}
}
}

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

public class PersonalityCalculator
{
public int findAnswers(String options)
{
String[] StringArray = options.split(",");
int[] IntArray = new int[StringArray.length];
for(int i=0;i<StringArray.length;i++) {
IntArray[i]=Integer.parseInt(StringArray[i]);
}
return IntArray;
}

public String findYourBrainType(String options) {
int[] option = findAnswers(options);
int x = option[0]+option[1]+option[2]+option[4]+option[7]+option[9]+option[10]+option[11]+option[13]+option[17]+option[19];
int y = option[3]+option[5]+option[6]+option[12]+option[14]+option[15]+option[16]+option[18];
int z = 66 - x + y;
System.out.println("Your total score "+z);
if((z>=20)&&(z<=55))
return "Left-brained ";
if((z>=56)&&(z<=64))
return "No clear preference ";
if((z>=65)&&(z<=100))
return "Right-brained";
return "false";
}

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