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
15 changes: 15 additions & 0 deletions java/question-1-height-and-age/HeightClassification.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public enum HeightClassification {

TALL("Tall"),
SHORT("Short");

private String classification;

HeightClassification(String classification) {
this.classification = classification;
}

public String getClassification() {
return classification;
}
}
16 changes: 16 additions & 0 deletions java/question-1-height-and-age/HumanClassification.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public enum HumanClassification {

CHILD("Child"),
TEENAGER("Teenager"),
ADULT("Adult");

private String classification;

HumanClassification(String classification) {
this.classification = classification;
}

public String getClassification() {
return classification;
}
}
32 changes: 32 additions & 0 deletions java/question-1-height-and-age/Q1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
public class Q1 {

public static void main (final String [] args) {

try{
final int age = Integer.parseInt(args[0]);
final double height = Double.parseDouble(args[1]);
System.out.println(humanClassification(age) + " & " + heightClassification(height));
} catch (final Exception e) {
e.printStackTrace();
}
}

private static String humanClassification(final int age) {
if (age < 13) {
return HumanClassification.CHILD.getClassification();
} else if (age >= 13 && age < 20) {
return HumanClassification.TEENAGER.getClassification();
} else {
return HumanClassification.ADULT.getClassification();
}
}

private static String heightClassification(final double height) {
if (height > 1.7) {
return HeightClassification.TALL.getClassification();
} else {
return HeightClassification.SHORT.getClassification();
}

}
}
5 changes: 5 additions & 0 deletions java/question-2-intersection/Intersection.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public class Intersection {
public static int[] findIntersection(int[] arr1, int[] arr2) {

// TODO: [Your code here]
/**
* I assume this wants me to make the array have unique items, if thats the case I would use the
* java Set<> as it holds unique values. then find values that are common between the 2 arrays.
* If my assumption is correct an you insist in me doing it, let me know.
*/

}

Expand Down
31 changes: 29 additions & 2 deletions java/question-3-debug/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,35 @@ public static String toRna(String dna) {
return output;
};

public static void main(String [] args){
public static void main(String [] args){
//toRna method assumes that no other character would be sent in. so I chose to write a separate one
// stringTransformer("ACGTGGTCTTAA");
stringTransformer(args[0]);

}
}

private static void stringTransformer(final String input) {
char[] charArray = input.toCharArray();
String result = "";
for (int i = 0; i < charArray.length; i ++) {
result = toRna(charArray[i],result);
}

System.out.println(result);
}

private static String toRna(final char character, final String result) {
if (character == 'G') {
return result + 'C';
} else if (character == 'C') {
return result + 'G';
} else if (character =='T') {
return result + 'A';
} else if (character =='A') {
return result + 'U';
} else {
return result + character;
}
}

}