-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathabstractclass.java
46 lines (41 loc) · 1.02 KB
/
abstractclass.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
abstract class RRPaymentServices{
public double balance;
public int customerId;
public RRPaymentServices(double balance, int customerId) {
this.balance = balance;
this.customerId = customerId;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getBalance() {
return balance;
}
public int getCustomerId() {
return customerId;
}
public abstract void payBill(double amount);
}
class ShoppingPayment extends RRPaymentServices{
public static int counter=101;
public String paymentId;
public ShoppingPayment(double balance,int customerId){
super(balance,customerId);
}
public String getPaymentId() {
return paymentId;
}
public void payBill(double amount){
if(amount==getBalance()){
paymentId="S"+counter;
System.out.println("Congratulations!! Your payment of Rs."+getBalance()+" is successful! with payment id "+paymentId);
}
else if(amount>getBalance()){
System.out.println("Excess amount entered !! Please try again.");
}
else{
System.out.println("Insufficient amount entered!!please try again.");
}
counter++;
}
}