Skip to content

Commit

Permalink
Merge pull request #33 from Ren650119726/master
Browse files Browse the repository at this point in the history
作业及文章
  • Loading branch information
luoziyihao authored Mar 5, 2017
2 parents 6b1d42d + c37b7f5 commit 8c145f8
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 22 deletions.
16 changes: 8 additions & 8 deletions group17/102228177/work2_26/.classpath
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/dom4j-1.6.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
72 changes: 64 additions & 8 deletions group17/102228177/work2_26/src/com/coderising/array/ArrayUtil.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.coderising.array;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class ArrayUtil {
Expand All @@ -29,7 +31,10 @@ public static void main(String[] args) {

int[] a1 = {3, 5, 7,8};
int[] a2 = {4, 5, 6,7};
System.out.println(Arrays.toString(util.merge(a1, a2)));
// System.out.println(Arrays.toString(util.merge(a1, a2)));
System.out.println(Arrays.toString(util.fibonacci(15)));

System.out.println(Arrays.toString(util.getPrimes(23)));
}

/**
Expand Down Expand Up @@ -96,7 +101,9 @@ public int[] merge(int[] array1, int[] array2){
* @return
*/
public int[] grow(int [] oldArray, int size){
return null;
int[] newArray = new int[oldArray.length + size];
System.arraycopy(oldArray, 0, newArray, 0, newArray.length);
return newArray;
}

/**
Expand All @@ -107,7 +114,21 @@ public int[] grow(int [] oldArray, int size){
* @return
*/
public int[] fibonacci(int max){
return null;
List<Integer> list = new ArrayList<Integer>();
int f1 = 1, f2 = 1, f = 0;
list.add(f1);
list.add(f2);
while(f < max){
f = f1+f2;
f1 = f2;
f2 = f;
list.add(f);
}
int[] arr = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
arr[i] = list.get(i);
}
return arr;
}

/**
Expand All @@ -117,7 +138,24 @@ public int[] fibonacci(int max){
* @return
*/
public int[] getPrimes(int max){
return null;
List<Integer> list = new ArrayList<Integer>();
for (int i = 2; i < max; i++) {
boolean flag = true;
for (int j = 2; j < i; j++) {
if ( i % j == 0) {
flag = false;
break;
}
}
if(flag){
list.add(i);
}
}
int[] arr = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
arr[i] = list.get(i);
}
return arr;
}

/**
Expand All @@ -127,7 +165,23 @@ public int[] getPrimes(int max){
* @return
*/
public int[] getPerfectNumbers(int max){
return null;
List<Integer> list = new ArrayList<Integer>();
for (int i = 1; i <= max; i++){
int sum=0;
for (int j = 1; j < i; j++){
if(i%j==0){
sum+=j;
}
}
if(i==sum){
list.add(sum);
}
}
int[] arr = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
arr[i] = list.get(i);
}
return arr;
}

/**
Expand All @@ -139,8 +193,10 @@ public int[] getPerfectNumbers(int max){
* @return
*/
public String join(int[] array, String seperator){
return null;
String str = "";
for (int i = 0; i < array.length; i++) {
str += seperator+array[i];
}
return str.substring(1);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import org.dom4j.Element;



public class Struts {

public static View runAction(String actionName, Map<String,String> parameters) {
Expand Down Expand Up @@ -37,7 +35,7 @@ public static View runAction(String actionName, Map<String,String> parameters) {
Map<String, String> attribute = Dom4jUtil.getAttribute(element);
String className = attribute.get(actionName);
try {
Class clazz = Class.forName(className);
Class<?> clazz = Class.forName(className);
Object o = clazz.newInstance();
for (Map.Entry<String, String> entry : parameters.entrySet()) {
String key = entry.getKey();
Expand All @@ -46,14 +44,14 @@ public static View runAction(String actionName, Map<String,String> parameters) {
Method method = clazz.getDeclaredMethod(BeanUtil.setter(field.getName()),String.class);
method.invoke(o, value);
}
Method method = clazz.getDeclaredMethod("execute",null);
Method method = clazz.getDeclaredMethod("execute");
String str = (String) method.invoke(o);
Field[] fields = clazz.getDeclaredFields();
Map<String, String> map = new HashMap<String, String>();
for (Field field : fields) {
String fieldName = field.getName();
Method method2 = clazz.getDeclaredMethod(BeanUtil.getter(fieldName),null);
String ret = (String) method2.invoke(o, null);
Method method2 = clazz.getDeclaredMethod(BeanUtil.getter(fieldName));
String ret = (String) method2.invoke(o);
map.put(fieldName, ret);
}
View view = new View();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1204187480

102228177 http://note.youdao.com/noteshare?id=74a51e7f93461dfb77c69a1cf4755624&sub=004F10FA5D2046ABAA060F19C0D2A18F
http://note.youdao.com/noteshare?id=6d117ad0ead79eafee2a5308c00d6a3a

876385982 http://www.totoro-fly.com/?p=59

Expand Down

0 comments on commit 8c145f8

Please sign in to comment.