Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Constructors

 
Jane kamau
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following codepackage Accountcredit;
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34671
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jane,
Welcome to CodeRanch! I've added code tags to make your post easier to read.

I don't see the question though; just a block of code. Do note that in Java, classnames are camelcase by convention so accountcredit should be AccountCredit.
 
Matthew Brown
Bartender
Posts: 4567
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like Jeanne, I'm not quite sure what you're asking. But take a closer look at your credit() method:
Are you really sure that it's the amount variable that you want to be updating?
 
Jane kamau
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.My question is when I run the code the method credit is never called.The method credit is supposed to add the new amount that the user enters to the initial balance, but in my case it does'nt.This it what I get when I run it.

Account1 balance:$0.00
Account1 balance:$20.00
Enter deposit for account1: 90

adding 90.00 to account1 balance

account1 balance: 0.00
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know it's never being called? One way of checking would be to add a print statement. But I'm not convinced that's the problem. I think the problem is that the credit() method doesn't actually do anything, which is what my previous point was referring to.
 
Jane kamau
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats my point, why does it not do anything yet its supposed to.If you look at the method it is supposed to take the deposit amount and add it to the initial balance.This where I need help because I don't see anything wrong with the method credit.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jane kamau wrote:If you look at the method it is supposed to take the deposit amount and add it to the initial balance.

how do you say the amount is added to balance *in the code*?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have flipped the package, class naming conventions
 
Jane kamau
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys I have figured out where my error was and I have corrected it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic