import java.util.Scanner; public class Test1116 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Person a = new Person(); int age = scanner.nextInt(); a.setAge(age); System.out.println(a.getAge()); scanner.close(); } } class Person { private int age; int getAge() { if (age < 0){ age = 0; }else if(age > 200){ age = 200; } return age; } void setAge(int age) { this.age = age; } }
验证年龄
最新推荐文章于 2024-11-04 22:26:34 发布