领测软件测试网
软件测试技术门户cv/m.Y%@HZ
jUg s8_7s%P"s!l软件测试技术门户$bEI*Ng.].e
清单 2. RunRational
o#I~3hAoXbH 软件测试技术门户P8O*DFEO` `
nu
class Rational(n:Int, d:Int)
/My(J4m,d2Oqh,_{
h6pw Mdm:vx$Q // ... as before软件测试技术门户C&?
TL(c1X6J6D3Y
}
{,ZcN?x6B
Vc8jL*r,U2u$Hxobject RunRational extends Application软件测试技术门户2JJv`$v
fG7f:Q
{软件测试技术门户#Ox v+wqDDU,`a
val r1 = new Rational(1, 3)
Ug`F
T-C"z*o*t val r2 = new Rational(2, 5)软件测试技术门户q(P*KI?c
val r3 = r1 - r2软件测试技术门户yo%uy]:L
val r4 = r1 + r2
[$@s[r-Qn6JtVD` Console.println("r1 = " + r1)软件测试技术门户sB@|l
i:H _Cn
Console.println("r2 = " + r2)软件测试技术门户9X,X x9I }&^
Console.println("r3 = r1 - r2 = " + r3)
*Q}4[
j%oD Console.println("r4 = r1 + r2 = " + r4)
T5]e(Yd:O}软件测试技术门户
t
B4q0R:[