Im working with inheritanceand I have to make a class payment, and two class derived from the class payment, which are cashpayment and creditcardpayment.
My cashpayment is working ok, but when I try to compile my creditcardpayment it promtps me the next message
"cannot find symbol "constructor" creditcardpayment....
I havent finished yet my creditcardpayment class, but I believe I did the constructor
This my class Payment
CODE
public class Payment {
private double amount;
public Payment() {
amount = 0.0;
}
public Payment(double paymentAmount) {
amount = paymentAmount;
}
public void setPayment(double paymentAmount) {
amount = paymentAmount;
}
public double getPayment() {
return amount;
}
public void paymentDetails() {
System.out.println("The payment amount is " + amount);
}
public static void main(String[] args) {
// Create several test classes and invoke the paymentDetails method
Payment cash1 = new CashPayment(50.5);
Payment cash2 = new CashPayment(20.45);
Payment credit1 = new CreditCardPayment(10.5, "Fred", "10/5/2010", "123456789");
Payment credit2 = new CreditCardPayment(100, "Barney", "11/15/2009", "987654321");
System.out.println("Cash 1 details:");
cash1.paymentDetails();
System.out.println();
System.out.println("Cash 2 details:");
cash2.paymentDetails();
System.out.println();
System.out.println("Credit 1 details:");
credit1.paymentDetails();
System.out.println();
System.out.println("Credit 2 details:");
credit2.paymentDetails();
System.out.println();
}
}
and this is what I got so fr for the creditcard payment class
CODE
public class CreditCardPayment extends Payment {
public CreditCardPayment() {
super();
}
public CreditCardPayment(double paymentAmount) {
super(paymentAmount);
}
public String getCardName() {
return cardName;
}
public void setCardName(String cardName) {
this.cardName = cardName;
}
private String cardName;
}
and this is my creditcardpayment class, so far
public class CreditCardPayment extends Payment {
public CreditCardPayment() {
super();
}
public CreditCardPayment(double paymentAmount) {
super(paymentAmount);
}
public String getCardName() {
return cardName;
}
public void setCardName(String cardName) {
this.cardName = cardName;
}
private String cardName;
}
can you guys help me with this error? I have done the creditcashpayment class in different ways, but I still get the same compiling error, and that doesnt happen with my cashpayment class. I have checked over and over and I cant find whats wrong
*Edited to add the [ code] tags so we can read your code. In the future please
This post has been edited by pbl: 10 Nov, 2008 - 06:52 PM