Commit 7f879443 authored by Xiaoying Pu's avatar Xiaoying Pu

some ugly code

parent 04b69502
package tracker;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
/**
* type,stim,cond,rand,correct,default-compare,resp_1,resp_2
......@@ -16,13 +16,15 @@ public class Decision {
public final String MALE = "2*Man|2*Boy|2*Father|2*Male|2*Grandpa|2*Husband|2*Son|2*Uncle";
private final String female = "Girl, Female, Aunt, Daughter, Wife, Woman, Mother, Grandma";
public final List<String> FEMALE = Arrays.asList(female.split(", "));
public final String FEMALE = "2*Girl|2*Female|2*Aunt|2*Daughter|2*Wife|2*Woman|2*Mother|2*Grandma";
private final String unsplitScience = "Biology, Physics, Chemistry, Math, Geology, Astronomy, Engineering";
public final List<String> SCIENCE = Arrays.asList(unsplitScience.split(", "));
public final String SCIENCE = "2*Science|2*Physics|2*Chemistry|2*Math|2*Geology|2*Astronomy|2*Engineering";
private final String arts = "Philosophy, Humanities, Arts, Literature, English, Music, History";
public final List<String> ARTS = Arrays.asList(arts.split(", "));
public final String ARTS = "2*Philosophy|2*Humanities|2*Arts|2*Literature|2*English|2*Music|2*History";
private final String CONDITION_HIGH = "HWL|HWL|HWL|HWL|HWL|HWL|HWL";
private final String CONDITION_LOW = "LWL|LWL|LWL|LWL|LWL|LWL|LWL";
private final String typeChar = "2";
private final String typeRandomPick = "5";
......@@ -30,15 +32,101 @@ public class Decision {
private final String rand = "1";
private static final Random randomHandler = new Random();
public String getCategory1(String condition) {
List<String> result = new ArrayList<>();
result.add(typeRandomPick);
public String getCategory1() {
String[] result = new String[]{};
// WOW thread safe rand int's!!!
int maleOrFemale = ThreadLocalRandom.current().nextInt(0, 2);
if (maleOrFemale == 0) {
// a list of option for MT to choose from
result.add(MALE);
} else {
result.add(FEMALE);
}
if (condition.compareTo("HWL") == 0) {
result.add(CONDITION_HIGH);
} else if (condition.compareTo("LWL") == 0) {
result.add(CONDITION_LOW);
} else {
System.out.println("the ???");
}
result.add(rand);
int correctIndex = ThreadLocalRandom.current().nextInt(1, 3);
// some ugly code
if (correctIndex == 1) {
result.add("1");
result.add("2");
if (maleOrFemale == 0) {
result.add("Male");
result.add("Female");
} else {
result.add("Female");
result.add("Male");
}
} else {// second option is correct
result.add("2");
result.add("1");
if (maleOrFemale == 1) {
result.add("Male");
result.add("Female");
} else {
result.add("Female");
result.add("Male");
}
}
return String.join(",", result);
}
public String getCategory2() {
String[] result = new String[]{};
public String getCategory2(String condition) {
List<String> result = new ArrayList<>();
result.add(typeRandomPick);
// WOW thread safe rand int's!!!
int artsOrScince = ThreadLocalRandom.current().nextInt(0, 2);
if (artsOrScince == 0) {
// a list of option for MT to choose from
result.add(ARTS);
} else {
result.add(SCIENCE);
}
if (condition.compareTo("HWL") == 0) {
result.add(CONDITION_HIGH);
} else if (condition.compareTo("LWL") == 0) {
result.add(CONDITION_LOW);
} else {
System.out.println("the ???");
}
result.add(rand);
int correctIndex = ThreadLocalRandom.current().nextInt(1, 3);
// some ugly code
if (correctIndex == 1) {
result.add("1");
result.add("2");
if (artsOrScince == 0) {
result.add("Art");
result.add("Sciecne");
} else {
result.add("Science");
result.add("Art");
}
} else {// second option is correct
result.add("2");
result.add("1");
if (artsOrScince == 1) {
result.add("Art");
result.add("Science");
} else {
result.add("Science");
result.add("Art");
}
}
return String.join(",", result);
}
......
......@@ -38,6 +38,7 @@ public class UDPConstants {
"2,Versace,fashion,,2,1,",
"2,Toshiba,technology,,1,2,",
"2,Valentino,fashion,,2,1,"}; // got rid of an extra comma
//type,stim,cond,rand,correct,default-compare,resp_1,resp_2
// public static String[] TrialSet = {
// "2,Female,HWL,1,1,2,Female,Male",
// "2,Male,HWL,1,1,1,Male,Female",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment