FilteredAccount. A cash processing company has a class called Account used to process transactions:
Account objects interact with Transaction objects, which have many methods including:
Design a new class called FilteredAccount whose instances can be used in place of normal accounts but which
include the extra behavior of not processing transactions with a value of 0. More specifically, the new class should
indicate that a zero-valued transaction was approved but shouldn’t call the process method for it. Your class should
have a single constructor that accepts a parameter of type Client, and it should include the following method:
package inheritance;
public class FilteredAccount extends Account {
int total = 0;
int zero = 0;
// FileteredAccount class constructor takes Client object as argument
public FilteredAccount(Client c) {
super(c);
}
// returts the percent of transactions filtered out
public double percentFiltered() {
if (total == 0)
return 0.0;
return ((double) zero) * 100 / total;
}
// process method takes the Transaction class as argument
public boolean process(Transaction transaction) {
total += 1;
if (transaction.value() == 0) {
zero++;
return true;
}
return super.process(transaction);
}
public static void main(String[] args) {
}
}