-
Notifications
You must be signed in to change notification settings - Fork 1
/
DiemDanh2.java
91 lines (82 loc) · 2.29 KB
/
DiemDanh2.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
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
/*
* 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
*/
package NewNhanVien;
import java.util.*;
/**
*
* @author Administrator
*/
class SinhVien{
private String id;
private String ten;
private String lop;
private String sta;
public SinhVien(String id, String ten, String lop, String sta) {
this.id = id;
this.ten = ten;
this.lop = lop;
this.sta = sta;
}
public String getId() {
return id;
}
public String getLop() {
return lop;
}
public void setSta(String sta) {
this.sta = sta;
}
public int getDiem(){
int d = 10;
for(int i=0; i<this.sta.length(); i++){
if(this.sta.charAt(i) == 'v'){
d -= 2;
}
else if(this.sta.charAt(i) == 'm'){
d -= 1;
}
}
if(d < 0)
return 0;
return d;
}
public String getStatus(){
if(this.getDiem() == 0)
return " KDDK";
return "";
}
@Override
public String toString() {
return this.id + " " + this.ten + " " + this.lop + " " + this.getDiem() + this.getStatus();
}
}
public class DiemDanh2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<SinhVien> a = new ArrayList<>();
int n = sc.nextInt();
sc.nextLine();
for(int i=0; i<n; i++){
String id = sc.nextLine();
String ten = sc.nextLine();
String lop = sc.nextLine();
a.add(new SinhVien(id, ten, lop, ""));
}
for(int i=0; i<n; i++){
String[] s = sc.nextLine().split("\\s+");
for(int j=0; j<n; j++){
if(a.get(j).getId().equalsIgnoreCase(s[0])){
a.get(j).setSta(s[1]);
break;
}
}
}
String cmp = sc.nextLine();
for(SinhVien i : a){
if(i.getLop().equalsIgnoreCase(cmp))
System.out.println(i);
}
}
}