package 接口;
public abstract class Student {
String name;
int fee;
Student(String name)
{
this.name = name;
}
abstract void setFee(int fee);
abstract int getFee();
}
package 接口;
public interface Salary {
int getSalary();
}
package 接口;
public class Graduate extends Student implements Salary {
int salary;
Graduate(String name) {
super(name);
// TODO Auto-generated constructor stub
this.name = name;
}
@Override
public int getSalary() {
// TODO Auto-generated method stub
return 1500;
}
@Override
void setFee(int fee) {
// TODO Auto-generated method stub
}
@Override
int getFee() {
// TODO Auto-generated method stub
return 0;
}
boolean isLoan()
{
boolean flag=false;
if(salary<fee)
{
//System.out.println("需要贷款");
flag = true;
}
else
{
//System.out.println("不需要贷款");
flag=false;
}
return flag;
}
}
package 接口;
public class Teacher implements Salary{
String name;
int salary;
Teacher(String name)
{
}
public int getSalary() {
return 3000;
}
}
package 接口;
public class University {
void payOff(Salary s)
{
System.out.println("发放工资"+s.getSalary());
}
}
package 接口;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Graduate g = new Graduate("小亮");
g.setFee(100);
University u = new University();
u.payOff(g);
System.out.println("是否需要贷款"+g.isLoan());
Teacher t = new Teacher("大王");
u.payOff(t);
}
}