-
Notifications
You must be signed in to change notification settings - Fork 1
/
DiemDanh1.java
85 lines (77 loc) · 2.14 KB
/
DiemDanh1.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
/*
* 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 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 DiemDanh1 {
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;
}
}
}
for(SinhVien i : a){
System.out.println(i);
}
}
}