danhsachhv
package HocVien;
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
public class DSHV {
private HocVien []M;
private int n;
public DSHV() {
M=new HocVien[100];
n=0;
}
public void them(HocVien a){
if(n>=M.length){
System.out.println("Mang day");
return ;
}
M[n]=a;
n++;
}
public void dem(){
int k=0;
for(int i=0;i<n;i++)
if(M[i].dtb()>=5)
k++;
System.out.println("So hoc vien dat:"+k);
}
/* public void tim()throws IOException{
BufferedReader kbd=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Nhap ma hoc vien can tim:");
String x=kbd.readLine();
int i;
for( i=0;i<n;i++)
if(M[i].inma().equals(x))
{
M[i].get();
return;
}
if(i>n)
System.out.println("ko co hoc vien nay");
}*/
public HocVien Tim(String ma){
for(int i=0;i<n;i++)
if(ma.equals(M[i].getMa())){
return M[i];
}
return null;
}
public int Xoa(String ma){
int k=0;
if(ma.equals(M[n-1].getMa())){
k=1;
M[n]=null;
n--;
return k;
}
for(int i=0;i<n-1;i++){
if(ma.equals(M[i].getMa())){
k=1;
for(int j=i;j<n-1;j++){
M[j] = M[j + 1];
}
n--;
break;
}
}
return k;
}
public int tong(){
int s=0;
for(int i=0;i<n;i++)
{
s=s+1;
}
return s;
}
public int thongke(){
int a=0;
for(int i=0;i<n;i++)
if(M[i].dtb()>=5)
a++;
return a;
}
public static void main(String arg[])throws IOException{
DSHV ds=new DSHV();
HocVien a=new HocVien();
BufferedReader kbd=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Nhap so hoc vien :");
int x=Integer.parseInt(kbd.readLine());
for(int i=0;i<x;i++)
{
a.nhap();
ds.them(a);
}
}
}
Bạn đang đọc truyện trên: Truyen247.Pro