diff --git a/java/question-1-height-and-age/HeightClassification.java b/java/question-1-height-and-age/HeightClassification.java new file mode 100644 index 0000000..29eff0d --- /dev/null +++ b/java/question-1-height-and-age/HeightClassification.java @@ -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; + } +} diff --git a/java/question-1-height-and-age/HumanClassification.java b/java/question-1-height-and-age/HumanClassification.java new file mode 100644 index 0000000..6e95e89 --- /dev/null +++ b/java/question-1-height-and-age/HumanClassification.java @@ -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; + } +} diff --git a/java/question-1-height-and-age/Q1.java b/java/question-1-height-and-age/Q1.java new file mode 100644 index 0000000..5881945 --- /dev/null +++ b/java/question-1-height-and-age/Q1.java @@ -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(); + } + + } +} diff --git a/java/question-2-intersection/Intersection.java b/java/question-2-intersection/Intersection.java index 1c82a4b..28b7a56 100644 --- a/java/question-2-intersection/Intersection.java +++ b/java/question-2-intersection/Intersection.java @@ -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. + */ } diff --git a/java/question-3-debug/Debug.java b/java/question-3-debug/Debug.java index c6ed0d0..60aaa14 100644 --- a/java/question-3-debug/Debug.java +++ b/java/question-3-debug/Debug.java @@ -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; + } + } }