I have this problem :
I am trying to compile this :
public class Agora extends CreditCardPayment {
public void run() {
CashPayment ad1 = new CashPayment(12f);
ad1.paymentDetails();
CashPayment ad2 = new CashPayment(156.4f);
ad2.paymentDetails();
int cardnum1 = 1253462136;
CreditCardPayment ad3 = new CreditCardPayment(325.99f , "Visa" , "12/1/2015" , cardnum1);
ad3.paymentDetails();
int cardnum2 = 1235623151;
CreditCardPayment ad4 = new CreditCardPayment(999.99f , "Master" , "25/6/2016" , cardnum2);
ad4.paymentDetails();
}
}
but it keeps giving me this error :
Agora.java:3: error: constructor CreditCardPayment in class CreditCardPayment cannot be applied to given types; public class Agora extends CreditCardPayment {
required: float,String,String,int found: no arguments reason: actual and formal argument lists differ in length
And this is the CreditCardPayment class :
public class CreditCardPayment extends Payment{
public CreditCardPayment(float x ,String name , String exp_date , int card_num) {
super (x);
Card_name = name;
Expiration_date = exp_date;
Card_number = card_num;
}
public String paymentDetails() {
return super.paymentDetails() + "Card's name :" + Card_name + " , Expiration Date :" + Expiration_date + " , Card Number :" + Card_number ;
}
private String Card_name;
private String Expiration_date;
private int Card_number;
}
I am a computer science student and don't know much yet so please excuse me if this is just a silly mistake but I can't find it. Any help will be appreciated !
is-a
relationship. When you create aAgora
it also must create aCreditCardPayment
. Since you need to pass arguments to theCreditCardPayment
constructor, you need to usesuper()
similar to how it is used inCreditCardPayment
– clcto