第四天Java实训

public abstract class account {
    private double balance;
    public abstract double getInterest(double index,double time);

    public account(double balance) {
        this.balance = balance;
    }

    public account() {
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
}




public abstract class account {
    private double balance;
    public abstract double getInterest(double index,double time);

    public account(double balance) {
        this.balance = balance;
    }

    public account() {
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
}









public class accounttest {
    public static void main(String[] args) {
        account account = new fixeaccount(1000);
        System.out.println("本金:" + account.getBalance() + " 利息:" + account.getInterest(0.003,1));
    }
}



public class animal {
    private String name;
    private String color;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public animal() {
    }

    public animal(String name, String color) {
        this.name = name;
        this.color = color;
    }

    public void show(){
        System.out.println("名字叫"+ name +"颜色是:" + color);
    }
}




public class dog extends animal{
    private int toothNumber;

    public dog() {

    }

    public dog(int toothNumber) {
        this.toothNumber = toothNumber;
    }

    public dog(String name, String color, int toothNumber) {
        super(name, color);
        this.toothNumber = toothNumber;
    }
    @Override
    public void show(){
        super.show();
        System.out.println("牙齿数量:" + toothNumber);
    }
}




public class dogTest {
    public static void main(String[] args) {
        dog dog1 = new dog();
        dog1.show();
        dog dog2 = new dog("亚力"+" ","棕色",24);
        dog2.show();
    }
}



public abstract class person {
    String name;
    int age;
    double height;
    public person(){
        System.out.println("无参构造被调用了");
    }
    public void show(){
        System.out.println("我是Person...show()");
    }
    public abstract void say();
}






public abstract class Student extends person{
    public Student() {
        System.out.println("无参构造被调用");
    }
    @Override
    public void show(){
        System.out.println("我是Person...show()");
    }
    @Override
    public void say(){}
}




public class persontest {
    public static void main(String[] args) {
        Student student = new Student() {
        };
    }
}

public class person01 {
    String name;
    int age;

    public person01() {
    }

    public person01(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void show(){
        System.out.println("姓名:" + "年龄;");
    }
}





public class worker extends person01{
    double salary;
    @Override
    public void show(){
        System.out.println("薪水:");
    }

}



public class personworkertest {
    public static void main(String[] args) {
        person01 person01 = new person01();
        person01.show();
        worker worker = new worker();
        worker.show();
        person01 person011 = new worker();
        person011.show();
    }
}

public interface runner {
    void running();
}




public interface hunter extends runner{
    void hunt();
}



public class Chinese implements hunter{
    @Override
    public void hunt() {
        System.out.println("抓住一只小白兔");
    }

    @Override
    public void running() {
        System.out.println("正在全力奔跑");
    }
}



public class ChineseTest {
    public static void main(String[] args) {
        runner runner = new Chinese();
        runner.running();
        hunter hunter = new Chinese();
        hunter.hunt();
    }
}

public class Person {
    private String name;
    private int age;

    private void eat(){}
    private  void play(){};
}

public class Student extends Person{
    public Student() {
        super();
    }
    public Student(int studentID) {
        this.StudentID = studentID;
    }
    public Student(String name,int age,int studentID){
        super();
        this.StudentID=studentID;
    }
    private int StudentID;
    private void study(){}

}

public class Teacher {
    private int TeacherID;
    private void speak(){}
}

public class Worker {
    private double salary;
    private void working(){}
}

  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值