-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandle.java
More file actions
56 lines (48 loc) · 1.49 KB
/
Handle.java
File metadata and controls
56 lines (48 loc) · 1.49 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
import QuanLyBenhNhan.Model.BenhAnModel;
import QuanLyBenhNhan.Model.BenhNhanModel;
import java.util.ArrayList;
import java.util.Collections;
public class Handle {
private ArrayList<BenhNhan> list;
public Handle() {
this.list = new ArrayList<BenhNhan>();
}
public void add(BenhAn benhAn) {
this.list.add(benhAn);
}
public void add5BenhAn() {
for (int i = 0; i < 2; i++) {
System.out.println(String.format("Enter information (%d/%d)", i + 1, 2));
BenhAn benhAn = new BenhAn();
benhAn.addBenhAn();
this.add(benhAn);
}
}
public void printTuoiNhoHon10() {
System.out.println("Print all age:");
for (BenhNhan benhAn : list) {
if (((BenhAn) benhAn).getTinhTuoi() < 10) {
((BenhAn)benhAn).outBenhAn();
System.out.println("___");
}
}
}
public void sortAge(){
Collections.sort(list, new sortAge());
for(BenhNhan i : list){
((BenhAn) i).outBenhAn();
}
}
public void MaxTienPhi() {
double max = 0.0;
for(BenhNhan BN :list){
if(((BenhAn)BN).getTien() > max) max = ((BenhAn)BN).getTien();
}
for(int i = 0; i <list.size(); i++){
double tienVienPhiTungBenhNhan = ((BenhAn) list.get(i)).getTien();
if(tienVienPhiTungBenhNhan == max ){
((BenhAn) list.get(i)).outBenhAn();
}
}
}
}