[qlynv] quan ly nv

Class NV

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public abstract class NV {

    protected String maNV;

    protected  String tenNV;

    protected  String trinhdo;

    protected  long luongcb;

    public NV(){

       ;

       ;

       ;

        luongcb=0;

    }

    public NV(String mnv,String tnv,String td,long lcb){

        this.maNV=mnv;

        this.tenNV=tnv;

        this.trinhdo=td;

        this.luongcb=lcb;

    }

    public void Nhap(){

        BufferedReader r=new BufferedReader(new InputStreamReader(System.in));

        try{

            System.out.println("Nhap ma Nhan vien:");

            maNV=r.readLine();

            System.out.println("Nhap ten Nhan vien:");

            tenNV=r.readLine();

            System.out.println("Nhap trinh do hoc van:");

            trinhdo=r.readLine();

            System.out.println("Nhap luong co ban:");

            luongcb=Long.parseLong(r.readLine());

        }catch(IOException ex){}

    }

    public void Xuat(){

        System.out.println("ma Nhan vien:"+this.maNV);

        System.out.println("ten Nhan vien:"+this.tenNV);

        System.out.println("Trinh do:"+this.trinhdo);

        System.out.println("Muc luong co ban:"+this.luongcb+" dong");

       

    }

    abstract public long TinhLuong();

}

Class NVNC

package tuan7;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public class NVNC extends NV{

    private String chuyenmon;

    private long phucapdh;

    public NVNC(){

       ;

        phucapdh=0;

    }

    public NVNC(String mnv,String tnv,String td,long lcb,String cm,long pcdh){

        super(mnv,tnv,td,lcb);

        this.chuyenmon=cm;

        this.phucapdh=pcdh;

    }

    public void Nhap(){

        super.Nhap();

        BufferedReader r=new BufferedReader(new InputStreamReader(System.in));

        try{

            System.out.println("Nhap chuyen mon:");

            chuyenmon=r.readLine();         

            System.out.println("Nhap phu cap doc hai:");

            phucapdh=Long.parseLong(r.readLine());

        }catch(IOException ex){}

    }

    public void Xuat(){

        super.Xuat();

        System.out.println("Chuyen mon:"+this.chuyenmon);

        System.out.println("Phu cap DH:"+this.phucapdh+" dong");       

    }

    public long TinhLuong() {

        return luongcb+phucapdh;

    }

}

Class NVPV

package tuan7;

public class NVPV extends NV{

    public long TinhLuong() {

        return luongcb;

    }

}

Class NV

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public class NVQL extends NV{

    private String chuyenmon;

    private long phucapcv;

    public NVQL(){

       ;

        phucapcv=0;

    }

    public NVQL(String mnv,String tnv,String td,long lcb,String cm,long pccv){

        super(mnv,tnv,td,lcb);

        this.chuyenmon=cm;

        this.phucapcv=pccv;

    }

    public void Nhap(){

        super.Nhap();

        BufferedReader r=new BufferedReader(new InputStreamReader(System.in));

        try{

            System.out.println("Nhap chuyen mon:");

            chuyenmon=r.readLine();         

            System.out.println("Nhap phu cap cong viec:");

            phucapcv=Long.parseLong(r.readLine());

        }catch(IOException ex){}

    }

    public void Xuat(){

        super.Xuat();

        System.out.println("Chuyen mon:"+this.chuyenmon);

        System.out.println("Phu cap CV:"+this.phucapcv+" dong");       

    }

    public long TinhLuong() {

        return luongcb+phucapcv;

    }

}

Class main

public class Tuan7 {

    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

        // TODO code application logic here

        NV nv[];

        int n=0;

        nv=new NV[100];

        nv[0]=new NVQL();

        nv[0].Nhap();

        nv[1]=new NVPV();

        nv[1].Nhap();

        nv[2]=new NVNC();

        nv[2].Nhap();

        n=3;

        for(int i=0;i<n;i++)

            nv[i].Xuat();

    }

}

Bạn đang đọc truyện trên: AzTruyen.Top

Tags: