"depot M213"
This commit is contained in:
66
TD7/src/monney/Monnaie.java
Executable file
66
TD7/src/monney/Monnaie.java
Executable file
@ -0,0 +1,66 @@
|
||||
package monney;
|
||||
|
||||
public class Monnaie {
|
||||
|
||||
private int amount;
|
||||
private String currency;
|
||||
|
||||
/**
|
||||
* @return the currency
|
||||
*/
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param currency the currency to set
|
||||
*/
|
||||
public void setCurrency(String currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount
|
||||
*/
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param amount the amount to set
|
||||
*/
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public Monnaie (int a, String s) {
|
||||
this.amount = a;
|
||||
this.currency = s;
|
||||
}
|
||||
|
||||
public void add(Monnaie m) {
|
||||
if(this.currency.equals(m.currency) == true)
|
||||
{
|
||||
this.amount += m.amount;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
Monnaie m = (Monnaie)o;
|
||||
if ( this == null || m == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.currency == m.currency && this.amount==m.amount) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user