-
Notifications
You must be signed in to change notification settings - Fork 1
/
DanhSachDoanhNghiepNhanSinhVienThucTap1.java
50 lines (47 loc) · 1.35 KB
/
DanhSachDoanhNghiepNhanSinhVienThucTap1.java
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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
import java.util.*;
/**
*
* @author Administrator
*/
class DoanhNghiep implements Comparable<DoanhNghiep>{
private String ma;
private String ten;
private int so;
public DoanhNghiep(String ma, String ten, int so) {
this.ma = ma;
this.ten = ten;
this.so = so;
}
@Override
public int compareTo(DoanhNghiep b){
if(this.so != b.so)
return -Integer.compare(this.so, b.so);
return this.ma.compareTo(b.ma);
}
@Override
public String toString() {
return this.ma + " " + this.ten + " " + this.so;
}
}
public class DanhSachDoanhNghiepNhanSinhVienThucTap1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<DoanhNghiep> a = new ArrayList<>();
int n = sc.nextInt();
for(int i=0; i<n; i++){
sc.nextLine();
String ma = sc.nextLine();
String ten = sc.nextLine();
int so = sc.nextInt();
a.add(new DoanhNghiep(ma, ten, so));
}
Collections.sort(a);
for(DoanhNghiep i : a){
System.out.println(i);
}
}
}