Go Back   nV News Forums > Software Forums > General Software

Newegg Daily Deals

Thread Tools
Old 03-06-12, 07:32 PM   #1
Registered User
Join Date: Mar 2012
Posts: 1
Default Help java project (eclipse)

Tyler1991 is offline   Reply With Quote
Old 03-06-12, 08:36 PM   #2
Mahna Mahna
jcrox's Avatar
Join Date: Jul 2006
Location: Madison, Wi
Posts: 6,135
Default Re: Help java project (eclipse)

Part A

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:

class Account {

private Person person
private BigDecimal accountBalance;

public function setPerson(Person person) {
    this.person = person;

Now the attributes that belong to a person stay in the person class and you can still access them anywhere in 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.


MSI MPower Z87 | 4770k | CNPS9900MAX-B | 8GB G.Skill 1866 | EVGA GTX760 |ThermalTake 850w | X-Fi Titanium | HAF | Asus PA248Q | Lycosa | Death Adder | Win8 Pro 64


MSI GD65 | 2500k | H50 | 8GB G.skill | GTX570 | Ubuntu 13.10


17" Inspiron | i5 | 4GB DDR3 | 500GB HDD | Win7 Pro 64

jcrox is offline   Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

All times are GMT -5. The time now is 12:53 AM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.