为了账号安全,请及时绑定邮箱和手机立即绑定

大神求救感激不尽

下面是我的问题,老师布置了这样的作业,只是给了这些代码,不知从哪里入手,谁帮我把这个完整的补上去吗?感激不尽

贷款(Loan)分为许多种类,如租借(Lease)、抵押(Mortgage)、房屋贷款(HouseLoan)、汽车贷款(CarLoan)等

将Loan声明为抽象类,并指定所有的子类对象都应具有的行为,如计算月还款值(calculateMonthlyPayment),还款(makePayment),取得客户信息(getClientInfo),其中前两个因贷款种类不同计算方法也不同,可声明为抽象方法,Loan的所有子类都必须对这两个抽象方法进行重写

public abstract class Loan {

   public abstract float calculateMonthlyPayment();

   public abstract void makePayment(float amount);

     public Client getClientInfo() {  }

}

public interface Person {   

   public double calcuMonthlySalary(double sal, int type);   

 }  

public class Manager implements Person {   

     public Manager () {        }   

    public double calcuMonthlySalary(double sal, int type) {   

           System.out.println("Manager: "+(sal*type*3));   

            return sal*type*2;   

    }    }   

public class Employee implements Person {   

    public Employee () {        }      

     public double calcuMonthlySalary(double sal, int type) {   

        System.out.println("Employee: "+(sal*type*2));   

        return sal*type*1.5;   

    }    }    }  

public class SalaryManageTest {      

       public static void main(String[] args) throws Exception{   

   

        Person personService = (Person)Class.forName(args[0]).newInstance();   

            if (args[1] != null && args[1] != "" &&   

                    args[2] != null && args[2] != "")

           {   

                int sal = Integer.valueOf(args[1]).intValue();   

                int type = Integer.valueOf(args[2]).intValue();           

             //这里可以根据传入参数的不同,调用不同的实现类,   

            //如果再增加一类新的成员,也只要新增一个类,无需修改方法   

                personService.calcuMonthlySalary(sal, type);   

            }             

   }      

正在回答

举报

0/150
提交
取消

大神求救感激不尽

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号