100 java真题
导入Java . io . inputstreamreader;
导入Java . util . random;
公共类测试号{
私人A a
public void setA(A a) {
this.a = a
}
public A getA() {
返回a;
}
公共布尔判断(整数){
if(a . getv()& gt;num) {
system . out . println(" small ");
返回false
}
if(a . getv()& lt;num) {
system . out . println(" big ");
返回false
}否则{
system . out . println(" Bingo ");
返回true
}
}
公共静态void main(String[] args) {
test number t = new test number();
A a =新A(新Random()。nextInt(100));
刚毛藻;
BufferedReader str =新BufferedReader(
new InputStreamReader(system . in));
while (true) {
System.out.println("请输入数字猜一猜:");
尝试{
if(t . judge(integer . parse int(str . readline())){
打破;
}
} catch(异常e) {
System.out.println("输入错误,请重新输入:");
}
}
}
}
A级
private int v = 100;
公共A(内部v) {
this . setv(v);
}
公共A() {
}
public void setV(int v) {
this.v = v
}
public int getV() {
回归v;
}
}