qly cuoc inter

Thuê bao:

import java.util.Scanner;

public abstract class ThueBao{

    public String hoTen;

    public String diaChi;

    public String SDT;

    public ThueBao()

    {

       ;

       ;

       ;

    }

    public ThueBao(ThueBao a) {

        this.hoTen=a.hoTen;

        this.diaChi=a.diaChi;

        this.SDT=a.SDT;

    }

    public void nhapThueBao() {

        Scanner sc=new Scanner(System.in);

        System.out.println("Nhap ho ten: ");

        hoTen=sc.nextLine();

        System.out.println("Nhap dia chi: ");

        diaChi=sc.nextLine();

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

        SDT=sc.nextLine();

    }

    public void xuatThueBao() {

        System.out.println("Ho ten: "+hoTen);

        System.out.println("Dia chi: "+diaChi);

        System.out.println("SDT: "+SDT);

    }

    abstract public long cuoc();

}

Thuê bao DL:

import java.util.Scanner;

public class ThueBaoDL extends ThueBao{

    public int tienThueBao=30000;

    public int MB; 

    public ThueBaoDL()  {

        super();

        MB=0;

    }

    public ThueBaoDL(ThueBaoDL a)  {

        super(a);

        this.MB=a.MB;

    }

    public void nhapThueBao()  {

        super.nhapThueBao();

        Scanner sc=new Scanner(System.in);

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

        MB=sc.nextInt();

    }

    public void xuatThueBao() {

        System.out.println("So MB: "+MB);

    }

    public long tinhCuoc() {

       if(MB<2000)

           return tienThueBao+MB*55;

       else

           return tienThueBao+2000*55+(MB-2000)*41;

    }

    public long cuoc() {

        if (tinhCuoc()<400000)

            return tinhCuoc();

        else

                return 400000;

    }

}

Thuê bao TG:

import java.util.Scanner;

public class ThueBaoDL extends ThueBao{

    public int tienThueBao=30000;

    public int MB; 

    public ThueBaoDL()  {

        super();

        MB=0;

    }

    public ThueBaoDL(ThueBaoDL a) {

        super(a);

        this.MB=a.MB;

    }

    public void nhapThueBao()  {

        super.nhapThueBao();

        Scanner sc=new Scanner(System.in);

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

        MB=sc.nextInt();

    }

    public void xuatThueBao()  {

        System.out.println("So MB: "+MB);

    }

    public long tinhCuoc() {

       if(MB<2000)

           return tienThueBao+MB*55;

       else

           return tienThueBao+2000*55+(MB-2000)*41;

    }

    public long cuoc() {

        if (tinhCuoc()<400000)

            return tinhCuoc();

        else

                return 400000;

    }

}

Main:

import java.util.Scanner;

public class ThueBaoDL extends ThueBao{

    public int tienThueBao=30000;

    public int MB; 

    public ThueBaoDL()    {

        super();

        MB=0;

    }

    public ThueBaoDL(ThueBaoDL a)    {

        super(a);

        this.MB=a.MB;

    }

    public void nhapThueBao()  {

        super.nhapThueBao();

        Scanner sc=new Scanner(System.in);

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

        MB=sc.nextInt();

    }

    public void xuatThueBao() {

        System.out.println("So MB: "+MB);

    }

    public long tinhCuoc() {

       if(MB<2000)

           return tienThueBao+MB*55;

       else

           return tienThueBao+2000*55+(MB-2000)*41;

    }

    public long cuoc() {

        if (tinhCuoc()<400000)

            return tinhCuoc();

        else

                return 400000;

    }

}

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

Tags: