diff --git a/group14/296933284/DataStructuresTest/.classpath b/group14/296933284/DataStructuresTest/.classpath deleted file mode 100644 index 373dce4005..0000000000 --- a/group14/296933284/DataStructuresTest/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/group14/296933284/DataStructuresTest/.gitignore b/group14/296933284/DataStructuresTest/.gitignore deleted file mode 100644 index e32d56a40c..0000000000 --- a/group14/296933284/DataStructuresTest/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -/bin/ -/bin/ -/bin/ -/bin/ -/bin/ -/bin/ -/bin/ -/bin/ -/bin/ -/bin/ -/bin/ -/bin/ -/bin/ -/bin/ diff --git a/group14/296933284/Note/README.md b/group14/296933284/Note/README.md index 3b92cb5667..0b08b8f0bb 100644 --- a/group14/296933284/Note/README.md +++ b/group14/296933284/Note/README.md @@ -1,4 +1,5 @@ # 2017编程提高(Java)学习系列笔记链接 --- -1. [漫谈计算机组成 -- 微型计算机的硬件组成 2017-02-26](http://tennyson.ren/2017/02/25/%E6%BC%AB%E8%B0%88%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%B3%BB%E7%BB%9F%E7%BB%84%E6%88%90%20--%20%E5%BE%AE%E5%9E%8B%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%9A%84%E7%A1%AC%E4%BB%B6%E7%BB%84%E6%88%90/) \ No newline at end of file +1. [漫谈计算机组成 -- 微型计算机的硬件组成 2017-02-26](http://tennyson.ren/2017/02/25/%E6%BC%AB%E8%B0%88%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%B3%BB%E7%BB%9F%E7%BB%84%E6%88%90%20--%20%E5%BE%AE%E5%9E%8B%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%9A%84%E7%A1%AC%E4%BB%B6%E7%BB%84%E6%88%90/) +2. [Java中解析XML的方法 2017-03-04](http://tennyson.ren/2017/03/04/Java%E4%B8%AD%E8%A7%A3%E6%9E%90XML%E7%9A%84%E6%96%B9%E6%B3%95/#more) \ No newline at end of file diff --git a/group14/296933284/Note/test.txt b/group14/296933284/Note/test.txt deleted file mode 100644 index 95d09f2b10..0000000000 --- a/group14/296933284/Note/test.txt +++ /dev/null @@ -1 +0,0 @@ -hello world \ No newline at end of file diff --git a/group14/296933284/README.md b/group14/296933284/README.md index 023abf1e46..5c3f27c267 100644 --- a/group14/296933284/README.md +++ b/group14/296933284/README.md @@ -1,4 +1,4 @@ # 2017年编程提高(Java) 作业、练习、总结 -[DataStructuresTest --- 基本数据结构Java实现](https://github.com/Tennysons/coding2017/tree/master/group14/296933284/DataStructuresTest) +[coding --- 代码练习](https://github.com/Tennysons/coding2017/tree/master/group14/296933284/coding) [Note --- 2017编程提高(Java)学习系列笔记链接](https://github.com/Tennysons/coding2017/tree/master/group14/296933284/Note) diff --git a/group14/296933284/coding/.classpath b/group14/296933284/coding/.classpath new file mode 100644 index 0000000000..11ea08c22c --- /dev/null +++ b/group14/296933284/coding/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/group14/296933284/coding/.gitignore b/group14/296933284/coding/.gitignore new file mode 100644 index 0000000000..1ea200494a --- /dev/null +++ b/group14/296933284/coding/.gitignore @@ -0,0 +1,6 @@ +/bin/ +.eml +.iml +.idea +/lib/ +*.eml \ No newline at end of file diff --git a/group14/296933284/DataStructuresTest/.project b/group14/296933284/coding/.project similarity index 100% rename from group14/296933284/DataStructuresTest/.project rename to group14/296933284/coding/.project diff --git a/group14/296933284/coding/.settings/org.eclipse.core.resources.prefs b/group14/296933284/coding/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..9abffe377f --- /dev/null +++ b/group14/296933284/coding/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding//src/com/coderising/litestruts/StrutsTest.java=UTF-8 diff --git a/group14/296933284/DataStructuresTest/.settings/org.eclipse.jdt.core.prefs b/group14/296933284/coding/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from group14/296933284/DataStructuresTest/.settings/org.eclipse.jdt.core.prefs rename to group14/296933284/coding/.settings/org.eclipse.jdt.core.prefs diff --git a/group14/296933284/coding/src/com/coderising/array/ArrayUtil.java b/group14/296933284/coding/src/com/coderising/array/ArrayUtil.java new file mode 100644 index 0000000000..557f917c37 --- /dev/null +++ b/group14/296933284/coding/src/com/coderising/array/ArrayUtil.java @@ -0,0 +1,228 @@ +package com.coderising.array; + +import com.coding.basic.ArrayList; + +import java.util.Arrays; + + +/** + * Created by Tennyson on 2017/3/1. + */ +public class ArrayUtil { + + /** + * 给定一个整形数组a , 对该数组的值进行置换 + * 例如: a = [7, 9 , 30, 3] , 置换后为 [3, 30, 9,7] + * 如果 a = [7, 9, 30, 3, 4] , 置换后为 [4,3, 30 , 9,7] + * @param origin + * @return + */ + public void reverseArray(int[] origin) { + for (int i = 0, j = origin.length - 1; i < origin.length / 2; i++, j--) { + int temp = origin[j]; + origin[j] = origin[i]; + origin[i] = temp; + } + } + + /** + * 现在有如下的一个数组: int oldArr[]={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5} + * 要求将以上数组中值为0的项去掉,将不为0的值存入一个新的数组,生成的新数组为: + * {1,3,4,5,6,6,5,4,7,6,7,5} + * @param oldArray + * @return + */ + public int[] removeZero(int[] oldArray) { + + int i; + // 获取数组中第一个值为 0 的元素的位置 + for (i = 0; i < oldArray.length; i++) + if (oldArray[i] == 0) + break; + // 从第一个值为 0 的元素开始,用之后的非零元素覆盖之前值为 0 的元素,并记录非零元素的个数 + for (int j = i + 1; j < oldArray.length; j++) + if (oldArray[j] != 0) + oldArray[i++] = oldArray[j]; + + // 复制数组 + int[] newArray = new int[i]; + System.arraycopy(oldArray, 0, newArray, 0, i); + + return newArray; + } + + /** + * 给定两个已经排序好的整形数组, a1和a2 , 创建一个新的数组a3, 使得a3 包含a1和a2 的所有元素, 并且仍然是有序的 + * 例如 a1 = [3, 5, 7,8] a2 = [4, 5, 6,7] 则 a3 为[3,4,5,6,7,8] , 注意: 已经消除了重复 + * @param array1 + * @param array2 + * @return + */ + public int[] merge(int[] array1, int[] array2) { + int i = 0, j = 0; + ArrayList arrayList = new ArrayList(); + + // 比较两个数组的元素值,将较小的值存入arrayList + while (i < array1.length && j < array2.length) { + + if (array1[i] == array2[j]) { + arrayList.add(array1[i]); + i++; + j++; + } else if (array1[i] < array2[j]) { + arrayList.add(array1[i++]); + } else if (array1[i] > array2[j]) { + arrayList.add(array2[j++]); + } + } + + // 剩下一个数组还未比较完, 将其剩余元素存入arrayList + while (i < array1.length) arrayList.add(array1[i++]); + while (j < array2.length) arrayList.add(array2[j++]); + + return ArrayUtil.toArray(arrayList); + } + /** + * 把一个已经存满数据的数组 oldArray的容量进行扩展, 扩展后的新数据大小为oldArray.length + size + * 注意,老数组的元素在新数组中需要保持 + * 例如 oldArray = [2,3,6] , size = 3,则返回的新数组为 + * [2,3,6,0,0,0] + * @param oldArray + * @param size + * @return + */ + public int[] grow(int [] oldArray, int size) { + int[] newArray = new int[oldArray.length + size]; + + return newArray = Arrays.copyOf(oldArray, newArray.length); + } + + /** + * 斐波那契数列为:1,1,2,3,5,8,13,21...... ,给定一个最大值, 返回小于该值的数列 + * 例如, max = 15 , 则返回的数组应该为 [1,1,2,3,5,8,13] + * max = 1, 则返回空数组 [] + * @param max + * @return + */ + public int[] fibonacci(int max) { + + ArrayList arrayList = new ArrayList(); + arrayList.add(1); + arrayList.add(1); + + int i, num; + for (i = 2; (num = (int) (arrayList.get(i - 1)) + (int) (arrayList.get(i - 2))) < max; i++) + arrayList.add(num); + + return ArrayUtil.toArray(arrayList); + } + + /** + * 返回小于给定最大值max的所有素数数组 + * 例如max = 23, 返回的数组为[2,3,5,7,11,13,17,19] + * @param max + * @return + */ + public int[] getPrimes(int max) { + + ArrayList arrayList = new ArrayList(); + + for (int i = 2; i < max; i++) { + int k = (int) Math.sqrt(i), j; + for (j = 2; j <= k; j++) + if (i % j == 0) break; + + // 若是 j >= k + 1 表示 i 没有被整除 即 i 为素数 + if (j >= k + 1) + arrayList.add(i); + } + + return ArrayUtil.toArray(arrayList); + } + + /** + * 所谓“完数”, 是指这个数恰好等于它的因子之和,例如6=1+2+3 + * 给定一个最大值max, 返回一个数组, 数组中是小于max 的所有完数 + * @param max + * @return + */ + public int[] getPerfectNumbers(int max) { + + ArrayList arrayList = new ArrayList(); + + for (int i = 6; i < max; i += 2) { + + if (i == 6) { + arrayList.add(i); + continue; + } + + int factorSum = 0; + + if (i % 3 == 1 && i % 9 == 1) { + + boolean flag = false; + + if (i % 10 == 6 ) { + flag = true; + } + + if (i % 10 == 8) { + if (i % 100 == 28) { + flag = true; + } + } + + if (flag) { + + for (int j = 1; j <= (i / 2); j++) { + + if (i % j == 0) { + factorSum += j; + } + } + } + + } + + if (factorSum == i) { + arrayList.add(i); + } + + } + + return ArrayUtil.toArray(arrayList); + } + + // 将ArrayList对象转换为数组返回 + private static int[] toArray(ArrayList arrayList) { + int[] array = new int[arrayList.size()]; + + for (int i = 0; i < array.length; i++) + array[i] = (Integer) arrayList.get(i); + + return array; + } + + /** + * 用seperator 把数组 array给连接起来 + * 例如array= [3,8,9], seperator = "-" + * 则返回值为"3-8-9" + * @param array + * @param seperator + * @return + */ + public String join(int[] array, String seperator){ + + StringBuffer stringBuffer = new StringBuffer(); + + for (int i = 0; i < array.length - 1; i++) + stringBuffer.append("" + array[i] + seperator); + + stringBuffer.append(array[array.length - 1]); + + return stringBuffer.toString(); + } + + +} diff --git a/group14/296933284/coding/src/com/coderising/array/ArrayUtilTest.java b/group14/296933284/coding/src/com/coderising/array/ArrayUtilTest.java new file mode 100644 index 0000000000..1b1e7005b4 --- /dev/null +++ b/group14/296933284/coding/src/com/coderising/array/ArrayUtilTest.java @@ -0,0 +1,99 @@ +package com.coderising.array; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + +/** + * Created by damocles on 2017/3/1. + */ +public class ArrayUtilTest { + private ArrayUtil arrayUtil; + private int[] oldArray = null; + private int[] newArray = null; + + @Before + public void setUp() throws Exception { + arrayUtil = new ArrayUtil(); + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void reverseArray() throws Exception { + oldArray = new int[]{7, 9, 30, 3}; + newArray = new int[]{3, 30, 9, 7}; + arrayUtil.reverseArray(oldArray); + + Assert.assertArrayEquals(newArray, oldArray); + + oldArray = new int[]{3, 30, 9, 7, 4}; + newArray = new int[]{4, 7, 9, 30, 3}; + arrayUtil.reverseArray(oldArray); + + Assert.assertArrayEquals(newArray, oldArray); + } + + @Test + public void removeZero() throws Exception { + oldArray = new int[]{1, 3, 4, 5, 0, 0, 6, 6, 0, 5, 4, 7, 6, 7, 0, 5}; + newArray = new int[]{1, 3, 4, 5, 6, 6, 5, 4, 7, 6, 7, 5}; + + Assert.assertArrayEquals(newArray, arrayUtil.removeZero(oldArray)); + + } + + @Test + public void merge() throws Exception { + int[] a1 = {3, 5, 7, 8}; + int[] a2 = {4, 5, 6, 7}; + newArray = new int[]{3, 4, 5, 6, 7, 8}; + + Assert.assertArrayEquals(newArray, arrayUtil.merge(a1, a2)); + } + + @Test + public void grow() throws Exception { + oldArray = new int[]{2, 3, 6}; + newArray = new int[]{2, 3, 6, 0, 0, 0}; + int size = 3; + + Assert.assertArrayEquals(newArray, arrayUtil.grow(oldArray, size)); + } + + @Test + public void fibonacci() throws Exception { + newArray = new int[]{1, 1, 2, 3, 5, 8, 13}; + + Assert.assertArrayEquals(newArray, arrayUtil.fibonacci(15)); + } + + @Test + public void getPrimes() throws Exception { + newArray = new int[]{2, 3, 5, 7, 11, 13, 17, 19}; + + Assert.assertArrayEquals(newArray, arrayUtil.getPrimes(23)); + } + + @Test + public void getPerfectNumbers() throws Exception { + newArray = new int[]{6, 28, 496, 8128}; + System.out.println(33550336 % 27); + Assert.assertArrayEquals(newArray, arrayUtil.getPerfectNumbers(10000)); + } + + @Test + public void join() throws Exception { + oldArray = new int[]{3, 8, 9, 10, 2}; + String seperator = "-"; + String exception = "3-8-9-10-2"; + + Assert.assertEquals(exception, arrayUtil.join(oldArray, seperator)); + } + +} \ No newline at end of file diff --git a/group14/296933284/coding/src/com/coderising/litestruts/LoginAction.java b/group14/296933284/coding/src/com/coderising/litestruts/LoginAction.java new file mode 100644 index 0000000000..b76d6548b0 --- /dev/null +++ b/group14/296933284/coding/src/com/coderising/litestruts/LoginAction.java @@ -0,0 +1,44 @@ +package com.coderising.litestruts; + +/** + * 这是一个用来展示登录的业务类, 其中的用户名和密码都是硬编码的。 + * @author liuxin + * + */ +public class LoginAction{ + private String name ; + private String password; + private String message; + + public String getName() { + return name; + } + + public String getPassword() { + return password; + } + + public String execute() { + + if("test".equals(name) && "1234".equals(password)) { + this.message = "login successful"; + return "success"; + } + + this.message = "login failed,please check your user/pwd"; + + return "fail"; + } + + public void setName(String name){ + this.name = name; + } + + public void setPassword(String password){ + this.password = password; + } + + public String getMessage() { + return this.message; + } +} diff --git a/group14/296933284/coding/src/com/coderising/litestruts/Struts.java b/group14/296933284/coding/src/com/coderising/litestruts/Struts.java new file mode 100644 index 0000000000..0c83cf4507 --- /dev/null +++ b/group14/296933284/coding/src/com/coderising/litestruts/Struts.java @@ -0,0 +1,141 @@ +package com.coderising.litestruts; + +import org.dom4j.Attribute; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + + + +public class Struts { + + public static View runAction(String actionName, Map parameters) { + + /* + + 0. 读取配置文件struts.xml + + 1. 根据actionName找到相对应的class , 例如LoginAction, 通过反射实例化(创建对象) + 据parameters中的数据,调用对象的setter方法, 例如parameters中的数据是 + ("name"="test" , "password"="1234") , + 那就应该调用 setName和setPassword方法 + + 2. 通过反射调用对象的exectue 方法, 并获得返回值,例如"success" + + 3. 通过反射找到对象的所有getter方法(例如 getMessage), + 通过反射来调用, 把值和属性形成一个HashMap , 例如 {"message": "登录成功"} , + 放到View对象的parameters + + 4. 根据struts.xml中的 配置,以及execute的返回值, 确定哪一个jsp, + 放到View对象的jsp字段中。 + + */ + + SAXReader reader = new SAXReader(); + File file = new File("src/com/coderising/litestruts/struts.xml"); + View view = new View(); + + try { + // 加载配置文件 + Document doucment = reader.read(file); + Element struts = doucment.getRootElement(); + Iterator strutsIterator = struts.elementIterator(); + Element action = null; + Object obj = null; + + while (strutsIterator.hasNext()) { + action = (Element) strutsIterator.next(); + Attribute actionAttribute = action.attribute("name"); + + // 通过反射获取实例化对象 + if (actionAttribute.getValue().equals(actionName)) { + obj = Class.forName(action.attribute("class").getValue()).newInstance(); + break; + } + } + + Iterator> parametersIterator = parameters.entrySet().iterator(); + + while (parametersIterator.hasNext()) { + + Map.Entry entry = parametersIterator.next(); + + // 调用相应属性的setter方法 + Method setterMethod = obj.getClass().getMethod("set" + + toUpperFisrtLetter(entry.getKey()), String.class); + setterMethod.invoke(obj, entry.getValue()); + } + + Method exectueMethod= obj.getClass().getMethod("execute"); + String exectueValue = (String) exectueMethod.invoke(obj); + + // 获取类中的所有属性 + Field[] fields = obj.getClass().getDeclaredFields(); + HashMap fieldHashMap = new HashMap<>(); + + for(int i = 0; i < fields.length; i++){ + + String fieldName = fields[i].getName(); + + // 获取对应的getter方法 + Method getterMethod = obj.getClass().getMethod("get" + + toUpperFisrtLetter(fieldName)); + String fieldValue = (String) getterMethod.invoke(obj); + + fieldHashMap.put(fieldName, fieldValue); + } + + + view.setParameters(fieldHashMap); + + Iterator actionIterator = action.elementIterator(); + + while (actionIterator.hasNext()) { + Element result = (Element) actionIterator.next(); + Attribute resuAttribute = result.attribute("name"); + + if (resuAttribute.getValue().equals(exectueValue)) { + view.setJsp(result.getStringValue()); + break; + } + } + + } catch (DocumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + + return view; + } + + // 将字符串首字母大写 + @NotNull + private static String toUpperFisrtLetter(String str) { + String string = str.toLowerCase(); + char[] cs = string.toCharArray(); + // 首字母大写 + cs[0] -= 32; + + return String.valueOf(cs); + } + +} diff --git a/group14/296933284/coding/src/com/coderising/litestruts/StrutsTest.java b/group14/296933284/coding/src/com/coderising/litestruts/StrutsTest.java new file mode 100644 index 0000000000..ab335a0ea4 --- /dev/null +++ b/group14/296933284/coding/src/com/coderising/litestruts/StrutsTest.java @@ -0,0 +1,41 @@ +package com.coderising.litestruts; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; + + + +public class StrutsTest { + + @Test + public void testLoginActionSuccess() { + + String actionName = "login"; + + Map params = new HashMap(); + params.put("name","test"); + params.put("password","1234"); + + + View view = Struts.runAction(actionName,params); + + Assert.assertEquals("/jsp/homepage.jsp", view.getJsp()); + Assert.assertEquals("login successful", view.getParameters().get("message")); + } + + @Test + public void testLoginActionFailed() { + String actionName = "login"; + Map params = new HashMap(); + params.put("name","test"); + params.put("password","123456"); //密码和预设的不一致 + + View view = Struts.runAction(actionName,params); + + Assert.assertEquals("/jsp/showLogin.jsp", view.getJsp()); + Assert.assertEquals("login failed,please check your user/pwd", view.getParameters().get("message")); + } +} diff --git a/group14/296933284/coding/src/com/coderising/litestruts/View.java b/group14/296933284/coding/src/com/coderising/litestruts/View.java new file mode 100644 index 0000000000..07df2a5dab --- /dev/null +++ b/group14/296933284/coding/src/com/coderising/litestruts/View.java @@ -0,0 +1,23 @@ +package com.coderising.litestruts; + +import java.util.Map; + +public class View { + private String jsp; + private Map parameters; + + public String getJsp() { + return jsp; + } + public View setJsp(String jsp) { + this.jsp = jsp; + return this; + } + public Map getParameters() { + return parameters; + } + public View setParameters(Map parameters) { + this.parameters = parameters; + return this; + } +} diff --git a/group14/296933284/coding/src/com/coderising/litestruts/struts.xml b/group14/296933284/coding/src/com/coderising/litestruts/struts.xml new file mode 100644 index 0000000000..ea46090bc9 --- /dev/null +++ b/group14/296933284/coding/src/com/coderising/litestruts/struts.xml @@ -0,0 +1,11 @@ + + + + /jsp/homepage.jsp + /jsp/showLogin.jsp + + + /jsp/welcome.jsp + /jsp/error.jsp + + \ No newline at end of file diff --git a/group14/296933284/DataStructuresTest/src/com/coding/basic/ArrayList.java b/group14/296933284/coding/src/com/coding/basic/ArrayList.java similarity index 100% rename from group14/296933284/DataStructuresTest/src/com/coding/basic/ArrayList.java rename to group14/296933284/coding/src/com/coding/basic/ArrayList.java diff --git a/group14/296933284/DataStructuresTest/src/com/coding/basic/BinarySearchTree.java b/group14/296933284/coding/src/com/coding/basic/BinarySearchTree.java similarity index 100% rename from group14/296933284/DataStructuresTest/src/com/coding/basic/BinarySearchTree.java rename to group14/296933284/coding/src/com/coding/basic/BinarySearchTree.java diff --git a/group14/296933284/DataStructuresTest/src/com/coding/basic/Iterator.java b/group14/296933284/coding/src/com/coding/basic/Iterator.java similarity index 100% rename from group14/296933284/DataStructuresTest/src/com/coding/basic/Iterator.java rename to group14/296933284/coding/src/com/coding/basic/Iterator.java diff --git a/group14/296933284/DataStructuresTest/src/com/coding/basic/JavaTest.java b/group14/296933284/coding/src/com/coding/basic/JavaTest.java similarity index 100% rename from group14/296933284/DataStructuresTest/src/com/coding/basic/JavaTest.java rename to group14/296933284/coding/src/com/coding/basic/JavaTest.java diff --git a/group14/296933284/DataStructuresTest/src/com/coding/basic/LinkedList.java b/group14/296933284/coding/src/com/coding/basic/LinkedList.java similarity index 99% rename from group14/296933284/DataStructuresTest/src/com/coding/basic/LinkedList.java rename to group14/296933284/coding/src/com/coding/basic/LinkedList.java index 2a397e9bec..3c37904532 100644 --- a/group14/296933284/DataStructuresTest/src/com/coding/basic/LinkedList.java +++ b/group14/296933284/coding/src/com/coding/basic/LinkedList.java @@ -2,7 +2,6 @@ import java.util.Collection; -import org.junit.Test; /** * LinkedList (ͷĵ) ʵ 14С 296933284 @@ -105,6 +104,7 @@ public Object get(int index) { * ɾָλýڵ㣬ؽڵֵ */ public Object remove(int index) { + rangCheck(index); Node r = getPreNode(index); @@ -136,6 +136,7 @@ public Object removeLast() { // ȡָλõǰ㲢 private Node getPreNode(int index) { + rangCheck(index); if (index == 0) { diff --git a/group14/296933284/DataStructuresTest/src/com/coding/basic/List.java b/group14/296933284/coding/src/com/coding/basic/List.java similarity index 100% rename from group14/296933284/DataStructuresTest/src/com/coding/basic/List.java rename to group14/296933284/coding/src/com/coding/basic/List.java diff --git a/group14/296933284/DataStructuresTest/src/com/coding/basic/Queue.java b/group14/296933284/coding/src/com/coding/basic/Queue.java similarity index 100% rename from group14/296933284/DataStructuresTest/src/com/coding/basic/Queue.java rename to group14/296933284/coding/src/com/coding/basic/Queue.java diff --git a/group14/296933284/DataStructuresTest/src/com/coding/basic/Stack.java b/group14/296933284/coding/src/com/coding/basic/Stack.java similarity index 100% rename from group14/296933284/DataStructuresTest/src/com/coding/basic/Stack.java rename to group14/296933284/coding/src/com/coding/basic/Stack.java