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