diff --git a/group16/2562124714/.idea/dictionaries/zhangwj.xml b/group16/2562124714/.idea/dictionaries/zhangwj.xml
new file mode 100644
index 0000000000..d07fd80ae1
--- /dev/null
+++ b/group16/2562124714/.idea/dictionaries/zhangwj.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/group16/2562124714/.idea/misc.xml b/group16/2562124714/.idea/misc.xml
new file mode 100644
index 0000000000..e97ef03f44
--- /dev/null
+++ b/group16/2562124714/.idea/misc.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/group16/2562124714/.idea/modules.xml b/group16/2562124714/.idea/modules.xml
new file mode 100644
index 0000000000..c3fdba38f0
--- /dev/null
+++ b/group16/2562124714/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/group16/2562124714/.idea/workspace.xml b/group16/2562124714/.idea/workspace.xml
new file mode 100644
index 0000000000..d357c0f9a1
--- /dev/null
+++ b/group16/2562124714/.idea/workspace.xml
@@ -0,0 +1,780 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ binaryTree.PriOder
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/group16/2562124714/2562124714.iml b/group16/2562124714/2562124714.iml
new file mode 100644
index 0000000000..3a8ffcf1f5
--- /dev/null
+++ b/group16/2562124714/2562124714.iml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/group16/2562124714/src/Test/ArrayListTest.java b/group16/2562124714/src/Test/ArrayListTest.java
new file mode 100644
index 0000000000..9bd8f2aeca
--- /dev/null
+++ b/group16/2562124714/src/Test/ArrayListTest.java
@@ -0,0 +1,70 @@
+package Test;
+
+import com.coding.basic.ArrayList;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangwj on 2017/2/23.
+ */
+public class ArrayListTest {
+ private static ArrayList arraylist = new ArrayList();
+ @BeforeClass
+ public static void setUp() throws Exception {
+
+ System.out.println("初始化变量");
+ for (Integer i = 0; i < 5; i++)
+ {
+ arraylist.add(i);
+ }
+
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void add() throws Exception {
+ Integer i = arraylist.size();
+ Integer AddElement = 999;
+ arraylist.add(AddElement);
+ assertEquals(i + 1, arraylist.size());
+ assertEquals(AddElement, arraylist.get(arraylist.size()));
+ arraylist.remove(arraylist.size());
+ }
+
+ @Test
+ public void add1() throws Exception {
+ Integer AddElement = 999;
+ arraylist.add(1, AddElement);
+ assertEquals(AddElement, arraylist.get(1));
+ arraylist.remove(1);
+ }
+
+ @Test
+ public void get() throws Exception {
+ assertEquals(null, arraylist.get(9999));
+ }
+
+ @Test
+ public void remove() throws Exception {
+ Integer i = (Integer)arraylist.get(1);
+ assertEquals(i, arraylist.remove(1));
+ arraylist.add(1, i);
+
+ }
+
+ @Test
+ public void size() throws Exception {
+ assertEquals(5, arraylist.size());
+
+ }
+
+}
\ No newline at end of file
diff --git a/group16/2562124714/src/Test/BinaryTreeNodeTest.java b/group16/2562124714/src/Test/BinaryTreeNodeTest.java
new file mode 100644
index 0000000000..7d8f4fdd01
--- /dev/null
+++ b/group16/2562124714/src/Test/BinaryTreeNodeTest.java
@@ -0,0 +1,100 @@
+package Test;
+
+import com.coding.basic.BinaryTreeNode;
+import com.coding.basic.TreeData;
+import com.sun.org.apache.bcel.internal.generic.NEW;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangwj on 2017/2/23.
+ */
+public class BinaryTreeNodeTest {
+ private BinaryTreeNode binaryTree = new BinaryTreeNode();
+ @Before
+ public void setUp() throws Exception {
+ //System.out.println("初始化二叉树,5, 4, 7");
+ TreeData element = new TreeData();
+ element.setT((Integer)5);
+ binaryTree.insert(element);
+ TreeData element2 = new TreeData();
+ element2.setT((Integer)4);
+ binaryTree.insert(element2);
+ TreeData element3 = new TreeData();
+ element3.setT((Integer)7);
+ binaryTree.insert(element3);
+// binaryTree.PriOder(this.binaryTree);
+ }
+
+ @Test
+ public void getData() throws Exception {
+ assertEquals(5, binaryTree.getData().getT());
+
+ }
+
+ @Test
+ public void setData() throws Exception {
+ TreeData element = new TreeData();
+ element.setT(6);
+ binaryTree.setData(element);
+ assertEquals(6, binaryTree.getData().getT());
+// binaryTree.PriOder(this.binaryTree);
+
+ }
+
+ @Test
+ public void getLeft() throws Exception {
+ assertEquals(4, binaryTree.getLeft().getData().getT());
+
+ }
+
+ @Test
+ public void setLeft() throws Exception {
+ TreeData element = new TreeData();
+ element.setT(2);
+ BinaryTreeNode NewTreeNode = new BinaryTreeNode();
+ NewTreeNode.setData(element);
+ binaryTree.setLeft(NewTreeNode);
+ assertEquals(2, binaryTree.getLeft().getData().getT());
+// binaryTree.PriOder(this.binaryTree);
+ }
+
+ @Test
+ public void getRight() throws Exception {
+ assertEquals(7, binaryTree.getRight().getData().getT());
+
+ }
+
+ @Test
+ public void setRight() throws Exception {
+ TreeData element = new TreeData();
+ element.setT(9);
+ BinaryTreeNode NewTreeNode = new BinaryTreeNode();
+ NewTreeNode.setData(element);
+ binaryTree.setRight(NewTreeNode);
+ assertEquals(9, binaryTree.getRight().getData().getT());
+ }
+
+ @Test
+ public void priOder() throws Exception {
+
+
+ }
+
+ @Test
+ public void insert() throws Exception {
+ TreeData element = new TreeData();
+ element.setT(2);
+ binaryTree.insert(element);
+ binaryTree.PriOder(this.binaryTree);
+ element.setT(9);
+ binaryTree.insert(element);
+ binaryTree.PriOder(this.binaryTree);
+ element.setT(8);
+// binaryTree.PriOder(this.binaryTree);
+
+ }
+
+}
\ No newline at end of file
diff --git a/group16/2562124714/src/Test/LinkedListTest.java b/group16/2562124714/src/Test/LinkedListTest.java
new file mode 100644
index 0000000000..276b389f15
--- /dev/null
+++ b/group16/2562124714/src/Test/LinkedListTest.java
@@ -0,0 +1,81 @@
+package Test;
+
+import com.coding.basic.LinkedList;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangwj on 2017/2/23.
+ */
+public class LinkedListTest {
+ private LinkedList linkedlist = new LinkedList();
+
+ @Before
+ public void Init()
+ {
+ System.out.println("初始化");
+ linkedlist.add(9.9);
+ linkedlist.add(9.99);
+ }
+
+
+ @Test
+ public void add() throws Exception {
+ linkedlist.add(8.8);
+ assertEquals(3, linkedlist.size());
+ System.out.println("after add size is " + linkedlist.size());
+ System.out.println("after add last element is " + linkedlist.get(linkedlist.size()));
+
+ }
+
+ @Test
+ public void add1() throws Exception {
+ linkedlist.add(2, 7.7);
+ assertEquals(3, linkedlist.size());
+ System.out.println("after add in 2th size is " + linkedlist.size());
+ System.out.println("after add 2th element is " + linkedlist.get(2));
+ }
+
+ @Test
+ public void get() throws Exception {
+ assertEquals(9.9, linkedlist.get(1));
+ }
+
+ @Test
+ public void remove() throws Exception {
+ assertEquals(9.9, linkedlist.remove(1));
+ }
+
+ @Test
+ public void size() throws Exception {
+ assertEquals(2, linkedlist.size());
+
+ }
+
+ @Test
+ public void addFirst() throws Exception {
+ linkedlist.addFirst(3.3);
+ assertEquals(3.3, linkedlist.get(1));
+// System.out.println();
+ }
+
+ @Test
+ public void addLast() throws Exception {
+ linkedlist.addLast(3.3);
+ assertEquals(3.3, linkedlist.get(linkedlist.size()));
+
+ }
+
+ @Test
+ public void removeFirst() throws Exception {
+ assertEquals(9.9, linkedlist.removeFirst());
+ }
+
+ @Test
+ public void removeLast() throws Exception {
+ assertEquals(9.99, linkedlist.removeLast());
+ }
+
+}
\ No newline at end of file
diff --git a/group16/2562124714/src/Test/QueueTest.java b/group16/2562124714/src/Test/QueueTest.java
new file mode 100644
index 0000000000..3f0557f262
--- /dev/null
+++ b/group16/2562124714/src/Test/QueueTest.java
@@ -0,0 +1,58 @@
+package Test;
+
+import com.coding.basic.Queue;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangwj on 2017/2/23.
+ */
+public class QueueTest {
+ private Queue queue = new Queue();
+ @Before
+ public void setUp() throws Exception {
+ System.out.println("初始化队列,元素为a,b,c,d");
+
+ String[] s = {"a", "b","c","d"};
+ for (String a:s
+ ) {
+ queue.enQueue(a);
+ }
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void enQueue() throws Exception {
+ queue.enQueue("dasdas");
+ assertEquals(5, queue.size());
+// assertEquals("dasdas", queue.);
+ }
+
+ @Test
+ public void deQueue() throws Exception {
+ assertEquals("a",queue.deQueue());
+ assertEquals(3, queue.size());
+
+ }
+
+ @Test
+ public void isEmpty() throws Exception {
+ assertEquals(false, queue.isEmpty());
+
+ }
+
+ @Test
+ public void size() throws Exception {
+ assertEquals(4, queue.size());
+
+ }
+
+}
\ No newline at end of file
diff --git a/group16/2562124714/src/Test/StackTest.java b/group16/2562124714/src/Test/StackTest.java
new file mode 100644
index 0000000000..0a36d4dc0f
--- /dev/null
+++ b/group16/2562124714/src/Test/StackTest.java
@@ -0,0 +1,57 @@
+package Test;
+
+import com.coding.basic.Stack;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by zhangwj on 2017/2/23.
+ */
+public class StackTest {
+ private Stack stack = new Stack();
+ @Before
+ public void setUp() throws Exception {
+ System.out.println("初始化栈,元素为a,b,c,d");
+
+ String[] s = {"a", "b","c","d"};
+ for (String a:s
+ ) {
+ stack.push(a);
+ }
+
+ }
+
+ @Test
+ public void push() throws Exception {
+ stack.push("aaa");
+ assertEquals(5, stack.size());
+ assertEquals("aaa", stack.peek());
+
+ }
+
+ @Test
+ public void pop() throws Exception {
+ assertEquals("d", stack.pop());
+ assertEquals(3, stack.size());
+
+ }
+
+ @Test
+ public void peek() throws Exception {
+ assertEquals("d", stack.peek());
+ assertEquals(4, stack.size());
+ }
+
+ @Test
+ public void isEmpty() throws Exception {
+ assertEquals(false, stack.isEmpty());
+ }
+
+ @Test
+ public void size() throws Exception {
+ assertEquals(4, stack.size());
+ }
+
+}
\ No newline at end of file
diff --git a/group16/2562124714/src/Test/TestRunner.java b/group16/2562124714/src/Test/TestRunner.java
new file mode 100644
index 0000000000..2bf465f832
--- /dev/null
+++ b/group16/2562124714/src/Test/TestRunner.java
@@ -0,0 +1,19 @@
+package Test;
+
+import org.junit.runner.JUnitCore;
+import org.junit.runner.notification.Failure;
+
+import javax.xml.transform.Result;
+
+/**
+ * Created by zhangwj on 2017/2/23. 调用测试类 可重复使用
+ */
+public class TestRunner {
+ public static void main(String[] args) {
+ org.junit.runner.Result result = JUnitCore.runClasses(BinaryTreeNodeTest.class);
+ for (Failure failure:result.getFailures()) {
+ System.out.println(failure.toString());
+ }
+ System.out.println(result.wasSuccessful());
+ }
+}
diff --git a/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java b/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java
index 680c20c419..a703ad3165 100644
--- a/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java
+++ b/group16/2562124714/src/com/coding/basic/BinaryTreeNode.java
@@ -1,5 +1,7 @@
package com.coding.basic;
+import java.util.Properties;
+
public class BinaryTreeNode {
private TreeData treeData;
@@ -25,11 +27,36 @@ public BinaryTreeNode getRight() {
public void setRight(BinaryTreeNode right) {
this.right = right;
}
+
+ public void PriOder(BinaryTreeNode Node)
+ {
+ if (Node.treeData != null)
+ {
+ System.out.println(Node.treeData.getT());
+ if (Node.left != null)
+ {
+ PriOder(Node.left);
+ }
+ if (Node.right != null)
+ {
+ PriOder(Node.right);
+ }
+ }
+
+ }
+
public BinaryTreeNode insert(TreeData o){
+ if (this.treeData == null && this.left == null && this.right == null)
+ {
+ this.treeData = o;
+ this.left = null;
+ this.right = null;
+ return null;
+ }
//遍历寻找元素应该插入的位置
- if (o.compareTo(this.treeData) < 0)
+ if (o.compareTo(this.treeData) <= 0)
{
if (this.left != null)
{
diff --git a/group16/2562124714/src/com/coding/basic/LinkedList.java b/group16/2562124714/src/com/coding/basic/LinkedList.java
index 8ef49d108a..f1de0a6839 100644
--- a/group16/2562124714/src/com/coding/basic/LinkedList.java
+++ b/group16/2562124714/src/com/coding/basic/LinkedList.java
@@ -5,6 +5,11 @@
import java.awt.*;
public class LinkedList implements List {
+ public LinkedList()
+ {
+ head = null;
+ this.Size = 0;
+ }
private Node head;
private int Size;
@@ -98,7 +103,7 @@ public int size(){
}
public void addFirst(Object o){
- Node NewNode = new Node(0);
+ Node NewNode = new Node(o);
if (null == this.head)
{
diff --git a/group16/2562124714/src/com/coding/basic/Stack.java b/group16/2562124714/src/com/coding/basic/Stack.java
index 61c92b2fe7..9dba3befa5 100644
--- a/group16/2562124714/src/com/coding/basic/Stack.java
+++ b/group16/2562124714/src/com/coding/basic/Stack.java
@@ -9,7 +9,7 @@ public class Stack {
// }
public void push(Object o){
- elementData.add(0);
+ elementData.add(o);
}
public Object pop(){
diff --git a/group16/2562124714/src/com/coding/basic/TestJunit.java b/group16/2562124714/src/com/coding/basic/TestJunit.java
new file mode 100644
index 0000000000..59ef43a992
--- /dev/null
+++ b/group16/2562124714/src/com/coding/basic/TestJunit.java
@@ -0,0 +1,17 @@
+package com.coding.basic;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Created by zhangwj on 2017/2/23.
+ */
+public class TestJunit {
+ @Test
+
+ public void testAdd()
+ {
+ String str = "Junit is working fine";
+ assertEquals("Junit is working fine", str);
+ }
+
+}
diff --git a/group16/2562124714/src/com/coding/basic/TestRunner.java b/group16/2562124714/src/com/coding/basic/TestRunner.java
new file mode 100644
index 0000000000..625ace52c6
--- /dev/null
+++ b/group16/2562124714/src/com/coding/basic/TestRunner.java
@@ -0,0 +1,25 @@
+package com.coding.basic;
+
+import com.sun.net.httpserver.Authenticator;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.notification.Failure;
+import org.junit.runners.model.TestClass;
+
+import javax.xml.transform.Result;
+
+/**
+ * Created by zhangwj on 2017/2/23.
+ */
+public class TestRunner {
+ public static void main(String[] args)
+ {
+ org.junit.runner.Result result = JUnitCore.runClasses(TestJunit.class);
+
+ for (Failure failure : result.getFailures())
+ {
+ System.out.println(failure.toString());
+ }
+
+ System.out.println(result.wasSuccessful());
+ }
+}
diff --git a/group16/2562124714/src/com/coding/basic/TreeData.java b/group16/2562124714/src/com/coding/basic/TreeData.java
index 3c39539b28..e79b7bd450 100644
--- a/group16/2562124714/src/com/coding/basic/TreeData.java
+++ b/group16/2562124714/src/com/coding/basic/TreeData.java
@@ -12,6 +12,8 @@ public T getT()
return t;
}
+ public void setT(T o) { t = o;}
+
@Override
public int compareTo(TreeData o) {
return getT().compareTo(o.getT());