uouo
This commit is contained in:
1 parent
183736b4e6
commit
ab5c3ee991
13 files changed
+305
No files matched your search
@@ -0,0 +1,31 @@
|
||||
package intro.bank;
|
||||
|
||||
public class ContoCorrente {
|
||||
private int balance;
|
||||
private String owner;
|
||||
|
||||
public ContoCorrente(String owner) {
|
||||
this.balance = 0;
|
||||
this.owner = owner;
|
||||
}
|
||||
public ContoCorrente(String owner, Integer balance) {
|
||||
this.balance = balance;
|
||||
this.owner = owner;
|
||||
}
|
||||
public int getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setBalance(int balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ContoCorrente[Owner: "+this.owner+" Balance: "+this.balance+"]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package intro.bank;
|
||||
|
||||
public class ContoCorrenteCurrency extends ContoCorrente {
|
||||
private Currency currency;
|
||||
|
||||
public ContoCorrenteCurrency(String owner, Currency currency) {
|
||||
super(owner);
|
||||
this.currency = currency;
|
||||
}
|
||||
public ContoCorrenteCurrency(String owner, Integer balance, Currency currency) {
|
||||
super(owner, balance);
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().substring(0,super.toString().length()-1)+" "+this.currency+"]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package intro.bank;
|
||||
|
||||
public enum Currency {
|
||||
EUR, USD, GBP
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package intro.bank;
|
||||
|
||||
public class TestContoCorrente {
|
||||
public static void main(String[] args) {
|
||||
ContoCorrenteCurrency c1 = new ContoCorrenteCurrency("c1", 1000, Currency.USD);
|
||||
ContoCorrenteCurrency c2 = new ContoCorrenteCurrency("c2", Currency.EUR);
|
||||
ContoCorrenteCurrency c3 = new ContoCorrenteCurrency("c3",2000, Currency.GBP);
|
||||
System.out.println(c1);
|
||||
System.out.println(c2);
|
||||
System.out.println(c3);
|
||||
|
||||
c2.setBalance(c2.getBalance()+200);
|
||||
c3.setBalance(c3.getBalance()-1200);
|
||||
|
||||
System.out.println(c2);
|
||||
System.out.println(c3);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user