-->
当前位置:首页 > 题库

PROGRAMMING:Inquire about sb

Luz5年前 (2021-05-10)题库409
There is a personnel array in which to query whether a person exists or not, the specific requirements are as follows: < br / >
1. Define person class: < br / >
A attribute name and age < br / >
B getters and setters of the two attributes < br / >
C is a construction method with parameters, which gives value to name and age, and a construction method without parameters, which assigns name to none and age to 1 < br / >
D toString method < br / >
public String toString() {
return "Person [name=" + name + ", age=" + age + "]";
}

2. In the main method, create a person array. The length of the array is input through the keyboard. The name and age of each object in the array are given through the keyboard. After creating the array, first display the information of all personnel, and then enter a name to query whether there is this person in the array? If yes, output the person's information; otherwise, output not found < br / >
###Input format:
Please write the input format here. For example: input 2 integers a and B with absolute value no more than 1000 in one line.
###Output format:
Please describe the output format here. For example, for each group of inputs, output the value of a + B in one line.
###Input example:
Here is a set of inputs. For example:
```in
three
tian 3
jerry 23
sun 22
su
```
```in
three
may 51
sunny 23
lily 32
lily
```
###Output example:
The corresponding output is given here. For example:
```out
Person [name=tian, age=3]
Person [name=jerry, age=23]
Person [name=sun, age=22]
not found
```
```out
Person [name=may, age=51]
Person [name=sunny, age=23]
Person [name=lily, age=32]
Query results:
Person [name=lily, age=32]
```







answer:If there is no answer, please comment