Help java project (eclipse)
Re: Help java project (eclipse)
For starters, get rid of the first name, last name, and id instance variables in the Account class. Create an instance variable of type person and add a setter method to the Account class:
The Account class needs an accountBalance instance variable. When dealing with money in Java it's best to use BigDecimal (import java.math.BigDecimal). Google it. You're also going to want to learn how to use BigDecimal.compareTo for the withdraw method.
Withdraw(amount): use the BigDecimal compareto method and check if the amount argument is > the account balance. If amount > balance print message else accountBalance = accountBalance - amount
Deposit(amount): add amount to accountBalance
public String inquiry(): return this.accountBalance.toString
For your toString method I would use StringBuilder. Again, if you don't know what that is Google it. Pull the account name and id from the person instance variable and concatenate with the current balance to create a string like the one shown in the instructions.
|All times are GMT -5. The time now is 04:44 PM.|
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Copyright ©1998 - 2014, nV News.