diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..410718f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +out/ +.idea +*.class +.DS_Store diff --git a/README.md b/README.md index c02997c..74eacb8 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,10 @@ 10. Submit a pull request with all your code. -Test Start time: Thu May 28, 7:00pm EST - -My End time: `` - -Test End time: Fri May 29, 10:00pm EST - +Test Start time: `Thu May 28, 7:00pm EST` +Test End time: `Fri May 29, 10:00pm EST` Total time: 27 hours + +My Start time: `Friday May 29, 4:25pm EST` +My End time: `Friday May 29, 5:20pm EST` +My Total time: about 1 hour \ No newline at end of file diff --git a/src/Exercises.java b/src/Exercises.java index ac85d45..1f50371 100644 --- a/src/Exercises.java +++ b/src/Exercises.java @@ -1,12 +1,12 @@ public class Exercises { static class Parent { - public String doStuff() { return ""; } + public String doStuff() { return "parent"; } } + static class Child extends Parent { - public String doStuff() { return ""; } - public String doStuff(String s) { return ""; } + public String doStuff() { return "child"; } + public String doStuff(String s) { return s; } } - } diff --git a/src/MyNode.java b/src/MyNode.java index 54f3213..85f89e9 100644 --- a/src/MyNode.java +++ b/src/MyNode.java @@ -2,9 +2,9 @@ * Created by amyquispe on 5/28/15. */ public abstract class MyNode { - private MyNode left; - private MyNode right; - private T data; + protected MyNode left; + protected MyNode right; + protected T data; public abstract MyNode getLeft(); @@ -13,6 +13,7 @@ public abstract class MyNode { public abstract T getData(); public abstract void insert(MyNode newNode); + public boolean contains(T someData){ if(getData()==null && someData == null){ return false; diff --git a/src/MyObject.java b/src/MyObject.java new file mode 100644 index 0000000..f3bfce3 --- /dev/null +++ b/src/MyObject.java @@ -0,0 +1,32 @@ +/** + * Created by pooja on 5/29/15. + */ +public class MyObject { + private String name; + private int age; + + public MyObject(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public int getAge() { + return age; + } + + public void setName(String name) { + this.name = name; + } + + public void setAge(int age) { + this.age = age; + } + + public boolean equals (MyObject one, MyObject two) { + return one.name.equals(two.name) && one.age == two.age; + } +} diff --git a/src/MyObjectNode.java b/src/MyObjectNode.java new file mode 100644 index 0000000..2d33164 --- /dev/null +++ b/src/MyObjectNode.java @@ -0,0 +1,53 @@ +/** + * Created by pooja on 5/29/15. + */ +public class MyObjectNode extends MyNode { + + public MyObjectNode() { + + } + + public MyNode getLeft() { + return left; + } + + public MyNode getRight() { + return right; + } + + public Object getData() { + return data; + } + + public void setLeft(MyNode left) { + this.left = left; + } + + public void setRight(MyNode right) { + this.right = right; + } + + public void setData(MyNode data) { + this.data = data; + } + + public void insert(MyNode newNode) { + + } + + public static void main(String[] args) { + MyObjectNode myNode = new MyObjectNode(); + MyObjectNode leftNode = new MyObjectNode(); + MyObjectNode rightNode = new MyObjectNode(); + myNode.setLeft(leftNode); + myNode.setRight(rightNode); + System.out.println(myNode.getLeft()); + System.out.println(myNode.getRight()); + System.out.println(myNode.getData()); // null + myNode.setData(leftNode); + System.out.println(myNode.getData()); // leftNode + System.out.println(myNode.contains(leftNode)); // true + System.out.println(myNode.contains(rightNode)); // false + } + +} diff --git a/src/Tests.java b/src/Tests.java index 377c274..7311397 100644 --- a/src/Tests.java +++ b/src/Tests.java @@ -44,7 +44,7 @@ public void test04MyObjectNodeImplementsSetters() throws Exception { ClassLoader cl = ClassLoader.getSystemClassLoader(); Class klass = cl.loadClass("MyObjectNode"); Method[] methods = klass.getMethods(); - ArrayList methodNames = new ArrayList<>(); + ArrayList methodNames = new ArrayList(); for (Method m : methods){ methodNames.add(m.getName()); } @@ -60,7 +60,7 @@ public void test05MyObjectHasNameAndAge() throws Exception { Class klass = cl.loadClass("MyObject"); Method[] methods = klass.getMethods(); - ArrayList methodNames = new ArrayList<>(); + ArrayList methodNames = new ArrayList(); for (Method m : methods){ methodNames.add(m.getName()); } diff --git a/unit-1-bootcamp-assessment.iml b/unit-1-bootcamp-assessment.iml new file mode 100644 index 0000000..fb8e866 --- /dev/null +++ b/unit-1-bootcamp-assessment.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file