Glame

第十五周Java作业

package Zh123;

public class ColaEmployee {
    protected String name;
    protected int months;
    protected int birthday;

    public ColaEmployee(String name, int months, int birthday) {
        super();
        this.name = name;
        this.months = months;
        this.birthday = birthday;
    }

    public String getName() {
        return name;
    }

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

    public int getMonths() {
        return months;
    }

    public void setMonths(int months) {
        this.months = months;
    }

    public int getBirthday() {
        return birthday;
    }

    public void setBirthday(int birthday) {
        this.birthday = birthday;
    }

    public void getSalary(int month) {

    }

}
package Zh123;

public class ColaEmployee {
    protected String name;
    protected int months;
    protected int birthday;

    public ColaEmployee(String name, int months, int birthday) {
        super();
        this.name = name;
        this.months = months;
        this.birthday = birthday;
    }

    public String getName() {
        return name;
    }

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

    public int getMonths() {
        return months;
    }

    public void setMonths(int months) {
        this.months = months;
    }

    public int getBirthday() {
        return birthday;
    }

    public void setBirthday(int birthday) {
        this.birthday = birthday;
    }

    public void getSalary(int month) {

    }

}
package Zh123;

public class ColaEmployee {
    protected String name;
    protected int months;
    protected int birthday;

    public ColaEmployee(String name, int months, int birthday) {
        super();
        this.name = name;
        this.months = months;
        this.birthday = birthday;
    }

    public String getName() {
        return name;
    }

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

    public int getMonths() {
        return months;
    }

    public void setMonths(int months) {
        this.months = months;
    }

    public int getBirthday() {
        return birthday;
    }

    public void setBirthday(int birthday) {
        this.birthday = birthday;
    }

    public void getSalary(int month) {

    }

}
package Zh123;

public class ColaEmployee {
    protected String name;
    protected int months;
    protected int birthday;

    public ColaEmployee(String name, int months, int birthday) {
        super();
        this.name = name;
        this.months = months;
        this.birthday = birthday;
    }

    public String getName() {
        return name;
    }

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

    public int getMonths() {
        return months;
    }

    public void setMonths(int months) {
        this.months = months;
    }

    public int getBirthday() {
        return birthday;
    }

    public void setBirthday(int birthday) {
        this.birthday = birthday;
    }

    public void getSalary(int month) {

    }

}
package Zh123;

public class ColaEmployee {
    protected String name;
    protected int months;
    protected int birthday;

    public ColaEmployee(String name, int months, int birthday) {
        super();
        this.name = name;
        this.months = months;
        this.birthday = birthday;
    }

    public String getName() {
        return name;
    }

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

    public int getMonths() {
        return months;
    }

    public void setMonths(int months) {
        this.months = months;
    }

    public int getBirthday() {
        return birthday;
    }

    public void setBirthday(int birthday) {
        this.birthday = birthday;
    }

    public void getSalary(int month) {

    }

}

package Zh123;

import java.util.Scanner;

interface Fruit {
}

class Apple implements Fruit {
    public Apple() {
        System.out.println("创建了一个苹果对象");
    }
}

class Banana implements Fruit {
    public Banana() {
        System.out.println("创建了一个香蕉对象");
    }
}

class Putao implements Fruit {
    public Putao() {
        System.out.println("创建了一个葡萄对象");
    }
}

class Gardener {
    public Fruit create() {
        Fruit f = null;
        Scanner input = new Scanner(System.in);
        String name = input.next();
        if (name.equals("苹果")) {
            f = new Apple();
        } else if (name.equals("香蕉")) {
            f = new Banana();
        } else if (name.equals("葡萄")) {
            f = new Putao();
        } else {
            System.out.println("不会种");
        }
        return f;

    }
}
package Zh123;

import java.util.Scanner;

interface Fruit {
}

class Apple implements Fruit {
    public Apple() {
        System.out.println("创建了一个苹果对象");
    }
}

class Banana implements Fruit {
    public Banana() {
        System.out.println("创建了一个香蕉对象");
    }
}

class Putao implements Fruit {
    public Putao() {
        System.out.println("创建了一个葡萄对象");
    }
}

class Gardener {
    public Fruit create() {
        Fruit f = null;
        Scanner input = new Scanner(System.in);
        String name = input.next();
        if (name.equals("苹果")) {
            f = new Apple();
        } else if (name.equals("香蕉")) {
            f = new Banana();
        } else if (name.equals("葡萄")) {
            f = new Putao();
        } else {
            System.out.println("不会种");
        }
        return f;

    }
}

 

posted on 2021-06-17 23:21  Glame  阅读(27)  评论(0编辑  收藏  举报

导航