From de149707cd59ab7aae692bb8f07c36bca0234ec2 Mon Sep 17 00:00:00 2001 From: SizweP Date: Sun, 15 Apr 2018 18:54:52 +0200 Subject: [PATCH 1/6] Create HeightClassification.java --- .../HeightClassification.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 java/question-1-height-and-age/HeightClassification.java 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; + } +} From d7cd85475a487d90c5cd31c9cb893439ea4f50b1 Mon Sep 17 00:00:00 2001 From: SizweP Date: Sun, 15 Apr 2018 18:55:36 +0200 Subject: [PATCH 2/6] Create HumanClassification.java --- .../HumanClassification.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 java/question-1-height-and-age/HumanClassification.java 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; + } +} From 0298e5d7b254c09bb69e5da462971e12869a9b1f Mon Sep 17 00:00:00 2001 From: SizweP Date: Sun, 15 Apr 2018 18:56:05 +0200 Subject: [PATCH 3/6] Create Q1.java --- java/question-1-height-and-age/Q1.java | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 java/question-1-height-and-age/Q1.java 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..455846e --- /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 = 1;//Integer.parseInt(args[0]); + final double height = 1.1;// 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(); + } + + } +} From 3a19dc135333c72aa828c4cf95b9c616264b4177 Mon Sep 17 00:00:00 2001 From: SizweP Date: Sun, 15 Apr 2018 18:57:29 +0200 Subject: [PATCH 4/6] Update Debug.java --- java/question-3-debug/Debug.java | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) 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; + } + } } From 74f66d729c3e7f49b9d9a26d6e4ecccd14690a0b Mon Sep 17 00:00:00 2001 From: SizweP Date: Sun, 15 Apr 2018 18:57:58 +0200 Subject: [PATCH 5/6] Update Q1.java --- java/question-1-height-and-age/Q1.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/question-1-height-and-age/Q1.java b/java/question-1-height-and-age/Q1.java index 455846e..5881945 100644 --- a/java/question-1-height-and-age/Q1.java +++ b/java/question-1-height-and-age/Q1.java @@ -3,8 +3,8 @@ public class Q1 { public static void main (final String [] args) { try{ - final int age = 1;//Integer.parseInt(args[0]); - final double height = 1.1;// Double.parseDouble(args[1]); + 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(); From 7045d56695be44808657dda7e08a441852ddafdb Mon Sep 17 00:00:00 2001 From: SizweP Date: Sun, 15 Apr 2018 18:58:37 +0200 Subject: [PATCH 6/6] Update Intersection.java --- java/question-2-intersection/Intersection.java | 5 +++++ 1 file changed, 5 insertions(+) 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. + */ }