From f018ba27c5cf5c2e2666bafac5d4e989b22d623d Mon Sep 17 00:00:00 2001 From: wangyt Date: Mon, 6 Mar 2017 10:39:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=96=87=E4=BB=B6=E7=A9=BA?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group14/864020162/.classpath | 6 ++ group14/864020162/.gitignore | 1 + group14/864020162/.project | 17 ++++ .../coderising/litestruts/LoginAction.java | 39 ++++++++ .../src/com/coderising/litestruts/Struts.java | 34 +++++++ .../src/com/coderising/litestruts/View.java | 23 +++++ .../com/datastructure/basic/ArrayList.java | 32 +++++++ .../datastructure/basic/BinaryTreeNode.java | 32 +++++++ .../src/com/datastructure/basic/Iterator.java | 7 ++ .../com/datastructure/basic/LinkedList.java | 46 +++++++++ .../src/com/datastructure/basic/List.java | 9 ++ .../src/com/datastructure/basic/Queue.java | 19 ++++ .../src/com/datastructure/basic/Stack.java | 22 +++++ .../src/com/datastructure/util/ArrayUtil.java | 96 +++++++++++++++++++ 14 files changed, 383 insertions(+) create mode 100644 group14/864020162/.classpath create mode 100644 group14/864020162/.gitignore create mode 100644 group14/864020162/.project create mode 100644 group14/864020162/src/com/coderising/litestruts/LoginAction.java create mode 100644 group14/864020162/src/com/coderising/litestruts/Struts.java create mode 100644 group14/864020162/src/com/coderising/litestruts/View.java create mode 100644 group14/864020162/src/com/datastructure/basic/ArrayList.java create mode 100644 group14/864020162/src/com/datastructure/basic/BinaryTreeNode.java create mode 100644 group14/864020162/src/com/datastructure/basic/Iterator.java create mode 100644 group14/864020162/src/com/datastructure/basic/LinkedList.java create mode 100644 group14/864020162/src/com/datastructure/basic/List.java create mode 100644 group14/864020162/src/com/datastructure/basic/Queue.java create mode 100644 group14/864020162/src/com/datastructure/basic/Stack.java create mode 100644 group14/864020162/src/com/datastructure/util/ArrayUtil.java diff --git a/group14/864020162/.classpath b/group14/864020162/.classpath new file mode 100644 index 0000000000..fb5011632c --- /dev/null +++ b/group14/864020162/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/group14/864020162/.gitignore b/group14/864020162/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/group14/864020162/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/group14/864020162/.project b/group14/864020162/.project new file mode 100644 index 0000000000..f16286d15c --- /dev/null +++ b/group14/864020162/.project @@ -0,0 +1,17 @@ + + + 2017Improve + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/group14/864020162/src/com/coderising/litestruts/LoginAction.java b/group14/864020162/src/com/coderising/litestruts/LoginAction.java new file mode 100644 index 0000000000..dcdbe226ed --- /dev/null +++ b/group14/864020162/src/com/coderising/litestruts/LoginAction.java @@ -0,0 +1,39 @@ +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/864020162/src/com/coderising/litestruts/Struts.java b/group14/864020162/src/com/coderising/litestruts/Struts.java new file mode 100644 index 0000000000..85e2e22de3 --- /dev/null +++ b/group14/864020162/src/com/coderising/litestruts/Struts.java @@ -0,0 +1,34 @@ +package com.coderising.litestruts; + +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字段中。 + + */ + + return null; + } + +} diff --git a/group14/864020162/src/com/coderising/litestruts/View.java b/group14/864020162/src/com/coderising/litestruts/View.java new file mode 100644 index 0000000000..07df2a5dab --- /dev/null +++ b/group14/864020162/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/864020162/src/com/datastructure/basic/ArrayList.java b/group14/864020162/src/com/datastructure/basic/ArrayList.java new file mode 100644 index 0000000000..5245563b7e --- /dev/null +++ b/group14/864020162/src/com/datastructure/basic/ArrayList.java @@ -0,0 +1,32 @@ +package com.datastructure.basic; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + public void add(Object o){ + + } + public void add(int index, Object o){ + + } + + public Object get(int index){ + return null; + } + + public Object remove(int index){ + return null; + } + + public int size(){ + return -1; + } + + public Iterator iterator(){ + return null; + } + +} diff --git a/group14/864020162/src/com/datastructure/basic/BinaryTreeNode.java b/group14/864020162/src/com/datastructure/basic/BinaryTreeNode.java new file mode 100644 index 0000000000..1c052a5005 --- /dev/null +++ b/group14/864020162/src/com/datastructure/basic/BinaryTreeNode.java @@ -0,0 +1,32 @@ +package com.datastructure.basic; + +public class BinaryTreeNode { + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public Object getData() { + return data; + } + public void setData(Object data) { + this.data = data; + } + public BinaryTreeNode getLeft() { + return left; + } + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + public BinaryTreeNode getRight() { + return right; + } + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Object o){ + return null; + } + +} diff --git a/group14/864020162/src/com/datastructure/basic/Iterator.java b/group14/864020162/src/com/datastructure/basic/Iterator.java new file mode 100644 index 0000000000..bee5d797c9 --- /dev/null +++ b/group14/864020162/src/com/datastructure/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.datastructure.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group14/864020162/src/com/datastructure/basic/LinkedList.java b/group14/864020162/src/com/datastructure/basic/LinkedList.java new file mode 100644 index 0000000000..a5b0b31c40 --- /dev/null +++ b/group14/864020162/src/com/datastructure/basic/LinkedList.java @@ -0,0 +1,46 @@ +package com.datastructure.basic; + +public class LinkedList implements List { + + private Node head; + + public void add(Object o){ + + } + public void add(int index , Object o){ + + } + public Object get(int index){ + return null; + } + public Object remove(int index){ + return null; + } + + public int size(){ + return -1; + } + + public void addFirst(Object o){ + + } + public void addLast(Object o){ + + } + public Object removeFirst(){ + return null; + } + public Object removeLast(){ + return null; + } + public Iterator iterator(){ + return null; + } + + + private static class Node{ + Object data; + Node next; + + } +} diff --git a/group14/864020162/src/com/datastructure/basic/List.java b/group14/864020162/src/com/datastructure/basic/List.java new file mode 100644 index 0000000000..633f1f73e2 --- /dev/null +++ b/group14/864020162/src/com/datastructure/basic/List.java @@ -0,0 +1,9 @@ +package com.datastructure.basic; + +public interface List { + public void add(Object o); + public void add(int index, Object o); + public Object get(int index); + public Object remove(int index); + public int size(); +} diff --git a/group14/864020162/src/com/datastructure/basic/Queue.java b/group14/864020162/src/com/datastructure/basic/Queue.java new file mode 100644 index 0000000000..d59788a45f --- /dev/null +++ b/group14/864020162/src/com/datastructure/basic/Queue.java @@ -0,0 +1,19 @@ +package com.datastructure.basic; + +public class Queue { + + public void enQueue(Object o){ + } + + public Object deQueue(){ + return null; + } + + public boolean isEmpty(){ + return false; + } + + public int size(){ + return -1; + } +} diff --git a/group14/864020162/src/com/datastructure/basic/Stack.java b/group14/864020162/src/com/datastructure/basic/Stack.java new file mode 100644 index 0000000000..6a1d31a3d4 --- /dev/null +++ b/group14/864020162/src/com/datastructure/basic/Stack.java @@ -0,0 +1,22 @@ +package com.datastructure.basic; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o){ + } + + public Object pop(){ + return null; + } + + public Object peek(){ + return null; + } + public boolean isEmpty(){ + return false; + } + public int size(){ + return -1; + } +} diff --git a/group14/864020162/src/com/datastructure/util/ArrayUtil.java b/group14/864020162/src/com/datastructure/util/ArrayUtil.java new file mode 100644 index 0000000000..3b6f9cc7aa --- /dev/null +++ b/group14/864020162/src/com/datastructure/util/ArrayUtil.java @@ -0,0 +1,96 @@ +package com.datastructure.util; + +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){ + + } + + /** + * 现在有如下的一个数组: 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){ + return null; + } + + /** + * 给定两个已经排序好的整形数组, 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){ + return null; + } + /** + * 把一个已经存满数据的数组 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){ + return null; + } + + /** + * 斐波那契数列为: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){ + return null; + } + + /** + * 返回小于给定最大值max的所有素数数组 + * 例如max = 23, 返回的数组为[2,3,5,7,11,13,17,19] + * @param max + * @return + */ + public int[] getPrimes(int max){ + return null; + } + + /** + * 所谓“完数”, 是指这个数恰好等于它的因子之和,例如6=1+2+3 + * 给定一个最大值max, 返回一个数组, 数组中是小于max 的所有完数 + * @param max + * @return + */ + public int[] getPerfectNumbers(int max){ + return null; + } + + /** + * 用seperator 把数组 array给连接起来 + * 例如array= [3,8,9], seperator = "-" + * 则返回值为"3-8-9" + * @param array + * @param s + * @return + */ + public String join(int[] array, String seperator){ + return null; + } + + +}