qlycasi

Class Casi

import java.util.Scanner;

public abstract class CaSy{

    public String hoTen;

    public int soNam;

    public int soDia;

    public int soBuoi;

    public CaSy() {

       ;

        soNam=0;

        soDia=0;

        soBuoi=0;

    }

    public CaSy(CaSy a) {

        this.hoTen=a.hoTen;

        this.soNam=a.soNam;

        this.soDia=a.soDia;

        this.soBuoi=a.soBuoi;

    }

    public void nhap() {

        Scanner sc=new Scanner(System.in);

        System.out.println("Nhap ten ca sy: ");

        hoTen=sc.nextLine();

        System.out.println("Nhap so nam lam viec: ");

        soNam=sc.nextInt();

        sc.nextLine();

        System.out.println("Nhap so dia ban duoc: ");

        soDia=sc.nextInt();

        sc.nextLine();

        System.out.println("Nhap so buoi trinh dien: ");

        soBuoi=sc.nextInt();

        sc.nextLine();

    }

    public void xuat() {

        System.out.println("Ten ca sy: "+hoTen);

        System.out.println("So nam lam viec: "+soNam);

        System.out.println("So dia ban duoc: "+soDia);

        System.out.println("So buoi trinh dien: "+soBuoi);

    }

    public abstract long luong();

}

Class CSCNT

public class CaSyCNT extends CaSy{

    public CaSyCNT() {

        super();

    }

    public CaSyCNT(CaSyCNT a) {

        super(a);

    }   

    public void nhap() {

        super.nhap();

    }   

    public void xuat() {

        super.xuat();

    }   

    public long luong() {

        /*return 3000+500*soNam+soDia+150*soBuoi;*/

        if(soDia>3000)

            return ((3000+500*soNam+soDia+150*soBuoi)+1000);

        else

            return 3000+500*soNam+soDia+150*soBuoi;

    }

}

Class casiNT

import java.util.Scanner;

public class CaSyNT extends CaSy{

    public int sogameshow;

    public CaSyNT() {

        super();

        sogameshow=0;

    }

    public CaSyNT(CaSyNT a) {

        super(a);

        this.sogameshow=a.sogameshow;

    }   

    public void nhap() {

        Scanner sc=new Scanner(System.in);

        super.nhap();

        System.out.println("Nhap so gameshow: ");

        sogameshow=sc.nextInt();

        sc.nextLine();

    }   

    public void xuat(){

        super.xuat();

        System.out.println("So gameshow: "+sogameshow);

    }

    public long luong() {

        return (long) (5000 + 500 * soNam + 1.2 * soDia + 300 * soBuoi + 500 * sogameshow);

    }

}

Class Quanly

import java.util.Scanner;

public class QuanLy{

    CaSy ds[ ];

    int soCS;

    Scanner sc=new Scanner(System.in);

    public QuanLy(int m) {

        ds=new CaSy[m];

    }

    public void them(CaSy t) {

        t.nhap();

        this.ds[soCS]=t;

        soCS=soCS+1;

    }

    public void hienthi() {

        for(int i=0 ;i<soCS ;i++) {

            this.ds[i].xuat();

            System.out.println("Tong tien luong: "+ds[i].luong());

            System.out.println();

        }

    }

    public void maxluong() {

        long a= ds[0].luong();

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

        {if(ds[i].luong()>= a)

               a=ds[i].luong();

        }

        for (int i=0; i<soCS; i++) {

            if (ds[i].luong()==a) {

                ds[i].xuat();

                System.out.println("Tong tien luong: "+ds[i].luong());

            }

        }

    }

    public void timCS(String ten) {

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

          if(ds[i].hoTen.equals(ten))

              ds[i].xuat();

    }

}

Class Ctysuoinhac

import java.util.Scanner;

public class CongTySuoiNhac {   

     * @param args the command line arguments

     */

    public static void main(String[] args) {

        QuanLy a;

        a=new QuanLy(50);

        Scanner sc=new Scanner(System.in);

        int chon;

        String nhap;

        do {

            System.out.println("0: Thoat");

            System.out.println("1: Nhap thong tin ca sy chua noi tieng");

            System.out.println("2: Nhap thong tin ca sy noi tieng");

            System.out.println("3: Hien thi danh sach thong tin tat ca ca sy");

            System.out.println("4: Tim thong tin ca sy 'Bang cach nhap ten ca sy'");

            System.out.println("5: Hien thi thong tin ca sy luong cao nhat");

            chon=sc.nextInt();

            sc.nextLine();

            switch(chon) {

                case 0:

                    return;

                case 1:

                    System.out.println("Nhap thong tin ca sy chua noi tieng: ");

                    a.them(new CaSyCNT());

                    break;

                case 2:

                    System.out.println("Nhap thong tin ca sy noi tieng: ");

                    a.them(new CaSyNT());

                    break;

                case 3:

                    System.out.println("Danh sach ca sy: ");

                    a.hienthi();

                    break;

                case 4:

                    System.out.println("Nhap ten ca sy: ");

                    nhap=sc.nextLine();

                    a.timCS(nhap);

                    break;

                case 5: {

                    System.out.println("Hien thi thong tin ca sy co muc luong cao nhat");

                    a.maxluong();

                    break;       }      }     }while(chon!=0);   } }

Bạn đang đọc truyện trên: TruyenTop.Vip

Tags: