Skip to content

Commit 058747b

Browse files
authored
Merge pull request onlyliuxin#3 from onlyliuxin/master
更新代码
2 parents 2629e03 + ae96cdf commit 058747b

File tree

740 files changed

+26309
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

740 files changed

+26309
-236
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ students/406400373/*
291291
students/549739951/*
292292
students/582161208/*
293293
students/592146505/*
294-
students/740707954/*
295294
students/844620174/*
296295
students/87049319/*
297296
students/183549495/*

dicegame.png

-14.8 KB
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.coderising.dp.bridge;
2+
3+
public class GraphicLibrary1 {
4+
public void draw_a_line(int x1,int y1,int x2,int y2){
5+
6+
}
7+
public void draw_a_circle(int x,int y, int r){
8+
9+
}
10+
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.coderising.dp.bridge;
2+
3+
public class GraphicLibrary2 {
4+
public void drawLine(int x1,int x2,int y1,int y2){
5+
6+
}
7+
public void drawCircle(int x,int y, int r){
8+
9+
}
10+
11+
}
Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
package com.coderising.dp.builder;
22

33
public class TagBuilder {
4-
4+
private TagNode rootNode;
5+
private TagNode currentNode;
6+
private TagNode parentNode;
57
public TagBuilder(String rootTagName){
6-
8+
rootNode = new TagNode(rootTagName);
9+
currentNode = rootNode;
10+
parentNode = null;
711
}
812

913
public TagBuilder addChild(String childTagName){
10-
11-
return null;
14+
parentNode = this.currentNode;
15+
this.currentNode = new TagNode(childTagName);
16+
parentNode.add(currentNode);
17+
return this;
1218
}
1319
public TagBuilder addSibling(String siblingTagName){
1420

15-
16-
return null;
21+
this.currentNode = new TagNode(siblingTagName);
22+
parentNode.add(this.currentNode);
23+
return this;
1724

1825
}
1926
public TagBuilder setAttribute(String name, String value){
20-
21-
return null;
27+
this.currentNode.setAttribute(name, value);
28+
return this;
2229
}
2330
public TagBuilder setText(String value){
24-
25-
return null;
31+
this.currentNode.setValue(value);
32+
return this;
2633
}
2734
public String toXML(){
28-
return null;
35+
return this.rootNode.toXML();
2936
}
3037
}

liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/builder/TagNode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public void setAttribute(String name, String value) {
1919
Attribute attr = findAttribute(name);
2020
if(attr != null){
2121
attr.value = value;
22+
return;
2223
}
2324

2425
attributes.add(new Attribute(name,value));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.coderising.dp.composite;
2+
3+
public class Line implements Shape {
4+
5+
@Override
6+
public void draw() {
7+
8+
9+
}
10+
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.coderising.dp.composite;
2+
3+
public class Rectangle implements Shape {
4+
5+
@Override
6+
public void draw() {
7+
// TODO Auto-generated method stub
8+
9+
}
10+
11+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.coderising.dp.composite;
2+
3+
public interface Shape {
4+
public void draw();
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.coderising.dp.composite;
2+
3+
public class Square implements Shape {
4+
5+
@Override
6+
public void draw() {
7+
// TODO Auto-generated method stub
8+
9+
}
10+
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.coderising.dp.composite;
2+
3+
public class Text implements Shape {
4+
5+
@Override
6+
public void draw() {
7+
// TODO Auto-generated method stub
8+
9+
}
10+
11+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.litejunit.extension;
2+
3+
import org.litejunit.v2.Test;
4+
import org.litejunit.v2.TestResult;
5+
6+
/**
7+
* A Decorator that runs a test repeatedly.
8+
*
9+
*/
10+
public class RepeatedTest extends TestDecorator {
11+
private int fTimesRepeat;
12+
13+
public RepeatedTest(Test test, int repeat) {
14+
super(test);
15+
if (repeat < 0)
16+
throw new IllegalArgumentException("Repetition count must be > 0");
17+
fTimesRepeat= repeat;
18+
}
19+
public int countTestCases() {
20+
return super.countTestCases()*fTimesRepeat;
21+
}
22+
public void run(TestResult result) {
23+
for (int i= 0; i < fTimesRepeat; i++) {
24+
if (result.shouldStop())
25+
break;
26+
super.run(result);
27+
}
28+
}
29+
public String toString() {
30+
return super.toString()+"(repeated)";
31+
}
32+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.litejunit.extension;
2+
3+
import org.litejunit.v2.Assert;
4+
import org.litejunit.v2.Test;
5+
import org.litejunit.v2.TestResult;
6+
7+
/**
8+
* A Decorator for Tests. Use TestDecorator as the base class
9+
* for defining new test decorators. Test decorator subclasses
10+
* can be introduced to add behaviour before or after a test
11+
* is run.
12+
*
13+
*/
14+
public class TestDecorator extends Assert implements Test {
15+
protected Test test;
16+
17+
public TestDecorator(Test test) {
18+
this.test= test;
19+
}
20+
/**
21+
* The basic run behaviour.
22+
*/
23+
public void basicRun(TestResult result) {
24+
test.run(result);
25+
}
26+
public int countTestCases() {
27+
return test.countTestCases();
28+
}
29+
public void run(TestResult result) {
30+
basicRun(result);
31+
}
32+
33+
public String toString() {
34+
return test.toString();
35+
}
36+
37+
public Test getTest() {
38+
return test;
39+
}
40+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.litejunit.extension;
2+
3+
import org.litejunit.v2.Protectable;
4+
import org.litejunit.v2.Test;
5+
import org.litejunit.v2.TestResult;
6+
7+
/**
8+
* A Decorator to set up and tear down additional fixture state.
9+
* Subclass TestSetup and insert it into your tests when you want
10+
* to set up additional state once before the tests are run.
11+
*/
12+
public class TestSetup extends TestDecorator {
13+
14+
public TestSetup(Test test) {
15+
super(test);
16+
}
17+
public void run(final TestResult result) {
18+
Protectable p= new Protectable() {
19+
public void protect() throws Exception {
20+
setUp();
21+
basicRun(result);
22+
tearDown();
23+
}
24+
};
25+
result.runProtected(this, p);
26+
}
27+
/**
28+
* Sets up the fixture. Override to set up additional fixture
29+
* state.
30+
*/
31+
protected void setUp() throws Exception {
32+
}
33+
/**
34+
* Tears down the fixture. Override to tear down the additional
35+
* fixture state.
36+
*/
37+
protected void tearDown() throws Exception {
38+
}
39+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.litejunit.sample;
2+
3+
import org.litejunit.extension.RepeatedTest;
4+
import org.litejunit.extension.TestSetup;
5+
import org.litejunit.sample.calculator.CalculatorSuite;
6+
import org.litejunit.v2.Test;
7+
import org.litejunit.v2.TestSuite;
8+
9+
10+
public class AllTest {
11+
/*public static Test suite(){
12+
13+
TestSuite suite= new TestSuite("All Test");
14+
suite.addTest(CalculatorSuite.suite());
15+
suite.addTestSuite(PersonTest.class);
16+
return suite;
17+
18+
}*/
19+
20+
public static Test suite(){
21+
22+
TestSuite suite= new TestSuite("All Test");
23+
suite.addTest(CalculatorSuite.suite());
24+
suite.addTest(new RepeatedTest(new TestSuite(PersonTest.class), 2));
25+
return new OverallTestSetup(suite);
26+
}
27+
28+
29+
static class OverallTestSetup extends TestSetup{
30+
31+
public OverallTestSetup(Test test) {
32+
super(test);
33+
34+
}
35+
protected void setUp() throws Exception {
36+
System.out.println("this is overall testsetup");
37+
}
38+
protected void tearDown() throws Exception {
39+
System.out.println("this is overall teardown");
40+
}
41+
42+
}
43+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.litejunit.sample;
2+
3+
import org.litejunit.v2.TestCase;
4+
5+
public class PersonTest extends TestCase {
6+
7+
Person p = null;
8+
protected void setUp() {
9+
p = new Person("andy",30);
10+
}
11+
public PersonTest(String name) {
12+
super(name);
13+
}
14+
public void testAge(){
15+
this.assertEquals(30, p.getAge());
16+
}
17+
public void testName(){
18+
this.assertEquals("andy", p.getName());
19+
}
20+
}
21+
class Person{
22+
private String name;
23+
private int age;
24+
25+
public Person(String name, int age) {
26+
27+
this.name = name;
28+
this.age = age;
29+
}
30+
public String getName() {
31+
return name;
32+
}
33+
public int getAge() {
34+
return age;
35+
}
36+
37+
38+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.litejunit.sample.calculator;
2+
3+
public class Calculator {
4+
5+
private int result = 0;
6+
public void add(int x){
7+
result += x;
8+
}
9+
public void subtract(int x){
10+
result -=x;
11+
}
12+
13+
public int getResult(){
14+
return this.result;
15+
}
16+
public static void main(String[] args){
17+
Calculator calculator = new Calculator();
18+
calculator.add(10);
19+
calculator.subtract(5);
20+
System.out.println(calculator.getResult());
21+
}
22+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.litejunit.sample.calculator;
2+
3+
import org.litejunit.v2.Test;
4+
import org.litejunit.v2.TestSuite;
5+
6+
public class CalculatorSuite {
7+
public static Test suite(){
8+
TestSuite suite= new TestSuite("Calculator All Test");
9+
suite.addTestSuite(CalculatorTest.class);
10+
return suite;
11+
}
12+
}

0 commit comments

Comments
 (0)