Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add solution. #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
out/
.idea
*.class
.DS_Store
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<insert here>`

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
8 changes: 4 additions & 4 deletions src/Exercises.java
Original file line number Diff line number Diff line change
@@ -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; }
}


}
7 changes: 4 additions & 3 deletions src/MyNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Created by amyquispe on 5/28/15.
*/
public abstract class MyNode<T> {
private MyNode left;
private MyNode right;
private T data;
protected MyNode left;
protected MyNode right;
protected T data;

public abstract MyNode getLeft();

Expand All @@ -13,6 +13,7 @@ public abstract class MyNode<T> {
public abstract T getData();

public abstract void insert(MyNode<T> newNode);

public boolean contains(T someData){
if(getData()==null && someData == null){
return false;
Expand Down
32 changes: 32 additions & 0 deletions src/MyObject.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
53 changes: 53 additions & 0 deletions src/MyObjectNode.java
Original file line number Diff line number Diff line change
@@ -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
}

}
4 changes: 2 additions & 2 deletions src/Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void test04MyObjectNodeImplementsSetters() throws Exception {
ClassLoader cl = ClassLoader.getSystemClassLoader();
Class<?> klass = cl.loadClass("MyObjectNode");
Method[] methods = klass.getMethods();
ArrayList<String> methodNames = new ArrayList<>();
ArrayList<String> methodNames = new ArrayList<String>();
for (Method m : methods){
methodNames.add(m.getName());
}
Expand All @@ -60,7 +60,7 @@ public void test05MyObjectHasNameAndAge() throws Exception {
Class<?> klass = cl.loadClass("MyObject");

Method[] methods = klass.getMethods();
ArrayList<String> methodNames = new ArrayList<>();
ArrayList<String> methodNames = new ArrayList<String>();
for (Method m : methods){
methodNames.add(m.getName());
}
Expand Down
12 changes: 12 additions & 0 deletions unit-1-bootcamp-assessment.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
</component>
</module>