-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathApp.java
More file actions
141 lines (106 loc) · 4.47 KB
/
Copy pathApp.java
File metadata and controls
141 lines (106 loc) · 4.47 KB
1
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
import java.util.ArrayList;
import java.util.Scanner;
import model.*;
public class App {
public static void main(String[] args) throws Exception {
// Student[] arrStudents = new Student[3]; //KHởi tạo mảng có kích thước = 5
// for(int i = 0; i < arrStudents.length; i++){
// Student student = new Student();
// System.out.println("Nhập thông tin học viên thứ " +(i+1));
// student.input();
// arrStudents[i] = student;
// }
// System.out.println("Thông tin học viên: ");
// for (Student student : arrStudents) {
// System.out.println(student);
// }
// ArrayList<String> listName = new ArrayList<>();
// listName.add("Ngoc");
// listName.add("Hung");
// listName.add("Hoa");
// listName.add("Tuan");
// for (String s : listName) {
// System.out.println(s);
// }
// System.out.println("Danh sách sau khi thêm: ");
// listName.add("Loan");
// for (String s : listName) {
// System.out.println(s);
// }
// listName.add(1, "Mai");
// System.out.println("Danh sách sau khi chèn: ");
// for (String s : listName) {
// System.out.println(s);
// }
// listName.set(1, "Son");
// System.out.println("Danh sách sau khi sửa: ");
// for (String s : listName) {
// System.out.println(s);
// }
// System.out.println("Số phần tử trong danh sách là: " + listName.size());
// boolean isCheck = listName.contains("Ngoc");
// System.out.println("Trong danh sách có ngoc không: " +isCheck);
// System.out.println("Ngoc nằm ở index: " + listName.indexOf("Ngoc"));
// listName.add("Ngoc");
// System.out.println("Ngoc nằm ở index cuối cùng là: " + listName.lastIndexOf("Ngoc"));
// System.out.println("Phần tử có indexx = 3 là : " + listName.get(3));
// listName.remove("Ngoc");
// listName.remove(4);
// System.out.println("Danh sách sau khi xoá: ");
// for (String string : listName) {
// System.out.println(string);
// }
// listName.clear();
Scanner sc = new Scanner(System.in);
System.out.println("Nhập số lượng học sinh: ");
int size = sc.nextInt();
ArrayList<Student> listStudents = new ArrayList<>();
for(int i = 0; i < size; i++){
System.out.println("Nhập thông học sinh thứ " +(i+1));
Student student = new Student();
student.input();
listStudents.add(student);
}
System.out.println("Danh sách học sinh: ");
for (Student students : listStudents) {
System.out.println(students);
}
sc.nextLine();
System.out.println("Nhập tên muốn tìm kiếm: ");
String name = sc.nextLine();
for(int i = 0; i < size; i++){
if(listStudents.get(i).getName().equalsIgnoreCase(name)){
System.out.println(listStudents.get(i));
listStudents.remove(listStudents.get(i));
}
}
System.out.println("Danh sách sau khi xoá: ");
for (Student student : listStudents) {
System.out.println(student);
}
// Person person1 = new Person(); //Tạo đối tượng person1
// // person1.name = "John";
// // person1.age = 22;
// // person1.address = "England";
// person1.setName("John");
// person1.setAge(20);
// person1.setAddress("England");
// System.out.println("Name: " +person1.getName());
// System.out.println("Age: " + person1.getAge());
// System.out.println("Address: " + person1.getAddress());
// person1.study("math");
// Person.setSchool();
// Person person2 = new Person();
// person2.name = "Lily";
// person2.study("English");
// Person person3 = new Person("Jane", 25, "England");
// System.out.println(person3.age);
// //person1.show();
// System.out.println(person1.toString());
// System.out.println(person2.toString());
// System.out.println(person3.toString());
// Student student1 = new Student();
// student1.input();
// System.out.println(student1.toString());
}
}