spring的最新用法...牛!!!
1
2
import org.springframework.beans.BeanUtils;
3
4
5
public class People {
6
public class Contants {
7
public static final int 情人節 = 120;
8
9
public static final int THING_ROSE = 1;
10
public static final int THING_KISS = 2;
11
public static final int THING_HUG = 3;
12
public static final int THING_ANGRY = 4;
13
public static final int THING_OTHER = 5;
14
15
public static final double MONEY = 100000.00;
16
public static final int LOVE = 100;
17
public static final int AGE = 30;
18
19
}
20
public static class Boy {
21
private boolean 有車;
22
private boolean 有房;
23
private double 賺錢;
24
private int 年齡 = 15;
25
26
public Boy() {
27
super();
28
}
29
public Boy(boolean isOwnCar,boolean isOwnHouse) {
30
有車 = isOwnCar;
31
有房 = isOwnHouse;
32
}
33
public Boy(boolean isOwnCar,boolean isOwnHouse,double partMoeny) {
34
有車 = isOwnCar;
35
有房 = isOwnHouse;
36
賺錢 = partMoeny;
37
}
38
39
public void setBoy(Boy boy) {
40
BeanUtils.copyProperties(this, boy);
41
}
42
public boolean givegirl(int thing) {
43
switch(thing) {
44
case Contants.THING_ROSE:
45
case Contants.THING_KISS:
46
case Contants.THING_HUG:
47
return true;
48
case Contants.THING_ANGRY:
49
case Contants.THING_OTHER:
50
return false;
51
}
52
return false;
53
}
54
public void 拼命賺錢() {
55
賺錢 ++;
56
}
57
public int get年齡() {
58
return 年齡;
59
}
60
public void set年齡(int 年齡) {
61
this.年齡 = 年齡;
62
}
63
public boolean is有車() {
64
return 有車;
65
}
66
public void set有車(boolean 有車) {
67
this.有車 = 有車;
68
}
69
public double get賺錢() {
70
return 賺錢;
71
}
72
public void set賺錢(double 賺錢) {
73
this.賺錢 = 賺錢;
74
}
75
public boolean is有房() {
76
return 有房;
77
}
78
public void set有房(boolean 有房) {
79
this.有房 = 有房;
80
}
81
82
}
83
public static class Girl {
84
private boolean 等;
85
private int 感情;
86
private int 生日;
87
88
89
public Boy 嫁給(Boy boy) {
90
return boy;
91
}
92
public boolean is等() {
93
return 等;
94
}
95
public void set等(boolean 等) {
96
this.等 = 等;
97
}
98
public int get感情() {
99
return 感情;
100
}
101
public void set感情(int 感情) {
102
this.感情 = 感情;
103
}
104
public int get生日() {
105
return 生日;
106
}
107
public void set生日(int 生日) {
108
this.生日 = 生日;
109
}
110
}
111
112
public boolean loveLoad(Boy boy,Girl girl) {
113
if (boy.is有房() && boy.is有車()) {
114
boy.setBoy(null);
115
girl.嫁給(boy);
116
} else {
117
if(girl.is等()) {
118
System.out.println("====1");
119
while (! (boy.get賺錢() > Contants.MONEY && girl.感情 > Contants.LOVE && boy.get年齡() < Contants.AGE)) {
120
System.out.println("====2");
121
for(int day = 1; day < 365 ; day ++) {
122
System.out.println("====3");
123
if(day == Contants.情人節) {
124
if(boy.givegirl(Contants.THING_ROSE)) {
125
girl.set感情(girl.get感情() + 1);
126
} else {
127
girl.set感情(girl.get感情() - 1);
128
}
129
}
130
if(day == girl.get生日()) {
131
if(boy.givegirl(Contants.THING_ROSE)) {
132
girl.set感情(girl.get感情() + 1);
133
} else {
134
girl.set感情(girl.get感情() - 1);
135
}
136
}
137
boy.拼命賺錢();
138
}
139
if(boy.is有房() && boy.is有車()) {
140
boy.setBoy(null);
141
girl.嫁給(boy);
142
return true;
143
}
144
boy.set年齡(boy.get年齡() + 1);
145
girl.set感情(girl.get感情() - 1);
146
}
147
if(boy.get年齡() > Contants.AGE) {
148
girl.嫁給(new Boy());
149
return false;
150
}
151
} else {
152
girl.嫁給(new Boy());
153
return false;
154
}
155
}
156
return false;
157
}
158
public static void main(String []args) {
159
People people = new People();
160
Boy litterBoy = new Boy();
161
litterBoy.set年齡(15);
162
litterBoy.set有房(false);
163
litterBoy.set有車(false);
164
litterBoy.set賺錢(0.00);
165
Girl goodGirl = new Girl();
166
goodGirl.set生日(100);
167
goodGirl.set感情(0);
168
goodGirl.set等(true);
169
System.out.println(people.loveLoad(litterBoy, goodGirl));
170
}
171
172

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172
