Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1139b17d66
@ -1,34 +1,34 @@
|
|||||||
package lab.three.one;
|
package lab.three.one;
|
||||||
|
|
||||||
|
|
||||||
public class Account
|
public class Account
|
||||||
{
|
{
|
||||||
private double balance;
|
private double balance;
|
||||||
public Account( double initialBalance )
|
public Account( double initialBalance )
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( initialBalance > 0.0 )
|
if ( initialBalance > 0.0 )
|
||||||
balance = initialBalance;
|
balance = initialBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void credit( double amount )
|
public void credit( double amount )
|
||||||
{
|
{
|
||||||
balance = balance + amount;
|
balance = balance + amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debit(double amount ) {
|
public void debit(double amount ) {
|
||||||
double newBalance = balance - amount;
|
double newBalance = balance - amount;
|
||||||
if (newBalance < 0) {
|
if (newBalance < 0) {
|
||||||
System.out.println("Debit amount exceeds balance.");
|
System.out.println("Debit amount exceeds balance.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
balance = newBalance;
|
balance = newBalance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getBalance()
|
public double getBalance()
|
||||||
{
|
{
|
||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user