public class SinhVien {
private String maSV, hoTen, ngaySinh, queQuan;
private boolean gioiTinh;// true: nam
private double diemTB;
public SinhVien() {
}
public SinhVien(String maSV, String hoTen, String ngaySinh,
String queQuan, boolean gioiTinh, double diemTB) {
this.maSV = maSV;
this.hoTen = hoTen;
this.ngaySinh = ngaySinh;
this.queQuan = queQuan;
this.gioiTinh = gioiTinh;
this.diemTB = diemTB;
}
public String getMaSV() {
return maSV;
}
public void setMaSV(String maSV) {
this.maSV = maSV;
}
public String getHoTen() {
return hoTen;
}
public void setHoTen(String hoTen) {
this.hoTen = hoTen;
}
public String getNgaySinh() {
return ngaySinh;
}
public void setNgaySinh(String ngaySinh) {
this.ngaySinh = ngaySinh;
}
public String getQueQuan() {
return queQuan;
}
public void setQueQuan(String queQuan) {
this.queQuan = queQuan;
}
public boolean isGioiTinh() {
return gioiTinh;
}
public void setGioiTinh(boolean gioiTinh) {
this.gioiTinh = gioiTinh;
}
public double getDiemTB() {
return diemTB;
}
public void setDiemTB(double diemTB) {
this.diemTB = diemTB;
}
public String xepLoai(){
if(diemTB<3.5) return " Kem ";
if(diemTB<5) return " yeu ";
if(diemTB<6.5) return " T Binh ";
if(diemTB<8) return " Kha ";
if(diemTB<9) return " Gioi ";
return " xuat sac ";
}
public String toString(){
return maSV +" "+hoTen +" "+ ngaySinh+" "+ queQuan
+ " " + ((gioiTinh)?" Nam ": " Nu " )+ diemTB + " "+xepLoai();
}
public static void main(String[] args) {
SinhVien a= new SinhVien("001","Le Van Long","12/2/2000","Nghe An",true,7.8);
System.out.println(a);
}
}
public void docFile(String tenFile){
try{
File f = new File(tenFile);
if(f.exists()){
Scanner read = new Scanner(f);
while (read.hasNext()){
Scanner line=new Scanner(read.nextLine());// đọc 1 dòng
// doc du lieu tren 1 dong
String ma, ht, ns, qq;
boolean gt;
double diem;
ma= line.next(); // 001
ht="";
while(!line.hasNextBoolean()) // ht= trien chieu
ht=ht + line.next()+" ";
ht=ht.trim();
gt=line.nextBoolean(); // gt = true
ns = line.next(); // 1/1/2000
qq="";
while(!line.hasNextDouble())
qq =qq + line.next() +" ";
qq=qq.trim();
diem=line.nextDouble();
a.add(new SinhVien(ma,ht,ns,qq,gt,diem));
}
}else System.out.println(" Khong ton tai file");
}catch(Exception e){
System.out.println(e.getMessage());
}
}