Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Homework help

 
matthew meltzer
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Matthew,

What is giving you trouble?
 
matthew meltzer
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to match the user1 in main with the user1 in createAccount, either by passing the former in or the latter out.
 
Steve Fahlbusch
Bartender
Posts: 602
7
Mac OS X Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why dont you ask your instructor in class? I ask as i teach.
 
matthew meltzer
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!
 
Winston Gutkowski
Bartender
Pie
Posts: 10217
58
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
matthew meltzer
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic