aspose file tools*
The moose likes Java in General and the fly likes Homework help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Homework help" Watch "Homework help" New topic
Author

Homework help

matthew meltzer
Greenhorn

Joined: Sep 08, 2012
Posts: 24

Here is the code below...I am not asking for you guys to solve it for me, but to helpgive me advice on where to start looking so I can learn to solve it on my own.

Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4174
    
  21

Hi Matthew,

What is giving you trouble?


Steve
matthew meltzer
Greenhorn

Joined: Sep 08, 2012
Posts: 24

The first question is the one i'm working on right now. Basically when you compile the code it shows 0.00 instead of the 500.00 it should.

I'm guessing the reason for this is because it's outputting information of a new account instead of the user1 account. Because I put in code to print out the other info (the persons name, info, etc) and it comes out as null which shows theres no values set to what is being printed.

So now that i know that it is printing out the information from a new account how do I get the code to print the information from user1 instead of the default values of a new account?
Keith Wood
Author
Ranch Hand

Joined: Aug 28, 2012
Posts: 38

You need to match the user1 in main with the user1 in createAccount, either by passing the former in or the latter out.


Author of the upcoming "Extending jQuery" book from Manning.
Steve Fahlbusch
Bartender

Joined: Sep 18, 2000
Posts: 559
    
    7

Why dont you ask your instructor in class? I ask as i teach.
matthew meltzer
Greenhorn

Joined: Sep 08, 2012
Posts: 24

Keith Wood wrote:You need to match the user1 in main with the user1 in createAccount, either by passing the former in or the latter out.


Could you give an example?

And The reason why I posted here instead of asking my instructor is because My professor usually takes a few days to reply to messages and the assignment is due tomorrow night. It is an online class so it makes communication a little more difficult.
Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
matthew meltzer wrote:
Keith Wood wrote:You need to match the user1 in main with the user1 in createAccount, either by passing the former in or the latter out.


Could you give an example?

And The reason why I posted here instead of asking my instructor is because My professor usually takes a few days to reply to messages and the assignment is due tomorrow night. It is an online class so it makes communication a little more difficult.


The User object (user1) at line 55 is not the same as line 61. The User object created in createAccount() is in local scope and is not the one that is being used to retrieve the balance.
Just to make your desired output, try removing line 61 and replace line 56 with and line 60 with

As for your overall code , I see a lot of flaws, like most of your methods are static. Also, you are passing the User object as parameter to retrieve the balance, while you are using the same object to call the method.

Try utilizing the principles of OOPS.
All The Best!!!


Programming is about thinking, NOT coding
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7639
    
  19

matthew meltzer wrote:Here is the code below...

Matthew.

You may notice that your thread is very tough to read; and that's because your code lines are far too long. I suggest you read the UseCodeTags (←click) page again thoroughly, and then use the 'Edit' key to break them up. I'd do it myself, but there are TONS of them.

It's also bad general coding practise.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
matthew meltzer
Greenhorn

Joined: Sep 08, 2012
Posts: 24

Vishal Shaw wrote:
matthew meltzer wrote:
Keith Wood wrote:You need to match the user1 in main with the user1 in createAccount, either by passing the former in or the latter out.


Could you give an example?

And The reason why I posted here instead of asking my instructor is because My professor usually takes a few days to reply to messages and the assignment is due tomorrow night. It is an online class so it makes communication a little more difficult.


The User object (user1) at line 55 is not the same as line 61. The User object created in createAccount() is in local scope and is not the one that is being used to retrieve the balance.
Just to make your desired output, try removing line 61 and replace line 56 with and line 60 with

As for your overall code , I see a lot of flaws, like most of your methods are static. Also, you are passing the User object as parameter to retrieve the balance, while you are using the same object to call the method.

Try utilizing the principles of OOPS.
All The Best!!!


Thank you! The code is from a homework assignment, I'm just supposed to edit it in response to the questions. BUt your post was very informative, thank you.

Winston Gutkowski wrote:
matthew meltzer wrote:Here is the code below...

Matthew.

You may notice that your thread is very tough to read; and that's because your code lines are far too long. I suggest you read the UseCodeTags (←click) page again thoroughly, and then use the 'Edit' key to break them up. I'd do it myself, but there are TONS of them.

It's also bad general coding practise.

Winston


Thanks for the advice. I'm new to posting code on message boards, but that makes alot of sense. I'll use that from now on.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Homework help