import javax.swing.JOptionPane;
public class Quicken {
public static void main(String[] args) {
Financial b[]={new ICBC(),new ABC(),new Futures(),new Stock()};
int now=0;
//b[1].withdraw(100);
//b1.deposit(50);
for(Financial m:b )
m.current(now);
JOptionPane.showMessageDialog(null,"hello world","sample",JOptionPane.WARNING_MESSAGE);
System.out.print("Your current money {1}quot;+now);
}
}
interface Financial{
float current(float now);
}
interface BankAccount extends Financial{
static int a=0;
public void withdraw(float money);
public void deposit(float money);
// float current(float now);
}
class ICBC implements BankAccount {
float a=0;
public void withdraw(float money){
a-=money;
System.out.println("Withdraw {1}quot;+money+" from "+this.getClass().getSimpleName());
}
public void deposit(float money){
a+=money;
System.out.println("Deposit {1}quot;+money+" from "+this.getClass().getSimpleName());
}
public float current(float now)
{ if(a>0)
System.out.println(this.getClass().getSimpleName() +" current money {1}quot;+a);
else
System.out.println(this.getClass().getSimpleName() +" current money {1}quot;+a);
now+=a;
return now;
}
}
class ABC implements BankAccount{
float a=0;
public void withdraw(float money){
a-=money;
System.out.println("Withdraw {1}quot;+money+" from "+this.getClass().getSimpleName());
}
public void deposit(float money){
a+=money;
System.out.println("Deposit {1}quot;+money+" from "+this.getClass().getSimpleName());
}
public float current(float now)
{ if(a>0)
System.out.println(this.getClass().getSimpleName() +" current money {1}quot;+a);
else
System.out.println(this.getClass().getSimpleName() +" current money {1}quot;+a);
now+=a;
return now;
}
}
interface Investment extends Financial{
static int a=0;
void lose(float money);
void earn(float money);
float current(float now);
}
class Futures implements Investment{
float a=0;
public void lose(float money){
a-=money;
System.out.println("Loss {1}quot;+money+" from "+this.getClass().getSimpleName());
}
public void earn(float money){
a+=money;
System.out.println("Earn {1}quot;+money+" from "+this.getClass().getSimpleName());
}
public float current(float now)
{ if(a>0)
System.out.println(this.getClass().getSimpleName() +" current money {1}quot;+a);
else
System.out.println(this.getClass().getSimpleName() +" current money {1}quot;+a);
now+=a;
return now;
}
}
class Stock implements Investment{
float a=0;
public void lose(float money){
a-=money;
System.out.println("Loss {1}quot;+money+" from "+this.getClass().getSimpleName());
}
public void earn(float money){
a+=money;
System.out.println("Earn {1}quot;+money+" from "+this.getClass().getSimpleName());
}
public float current(float now)
{ if(a>0)
System.out.println(this.getClass().getSimpleName() +" current money {1}quot;+a);
else
System.out.println(this.getClass().getSimpleName() +" current money {1}quot;+a);
now+=a;
return now;
}
}