What will be the output of the following program?
public class AccountTest {
public static void main(String[] args) {
Account account = new Account();
account.credit(200, "15-Oct-2013", "Hyderabad").print();
account.debit(50, "16-Oct-2013", "Warangal").print();
account.debit(75, "18-Oct-2013", "Guntur").print();
account.credit(15, "18-Oct-2013", "Khammam").print();
}
}
class Account {
double amount;
String lastTransactionDate, lastLocation;
int numberOfTranscations;
Account credit(double amount, String date, String location) {
numberOfTranscations++;
lastTransactionDate = date;
lastLocation = location;
amount += amount;
return this;
}
Account debit(double amount, String date, String location) {
if (this.amount >= amount) {
numberOfTranscations++;
lastTransactionDate = date;
lastLocation = location;
amount -= amount;
return this;
}
return null;
}
void print() {
System.out.println(numberOfTranscations + ". " + lastTransactionDate + " at " + lastLocation + " : " + amount);
}
}