| Time |
S |
Nick |
Message |
| 06:05 |
|
|
mr_lou joined ##friendlyjava |
| 11:41 |
|
|
nanoz joined ##friendlyjava |
| 11:46 |
|
|
rose joined ##friendlyjava |
| 11:47 |
|
rose |
hello |
| 11:57 |
|
|
rosebud joined ##friendlyjava |
| 11:58 |
|
rosebud |
hello |
| 15:33 |
|
|
Glasspasta joined ##friendlyjava |
| 15:41 |
|
Glasspasta |
hello |
| 15:42 |
|
aditsu |
hi |
| 15:42 |
|
Glasspasta |
I am looking for help with a java method |
| 15:42 |
|
Glasspasta |
https://pastebin.com/iTcSnhmQ |
| 15:43 |
|
Glasspasta |
there is my code |
| 15:43 |
|
aditsu |
Glasspasta: what is the purpose of line 2? |
| 15:46 |
|
|
Glasspasta_ joined ##friendlyjava |
| 15:47 |
|
Glasspasta_ |
line 2 take the current balance and adds it to the amount that is deposited |
| 15:47 |
|
aditsu |
no, line 2 is: "depAmount = 0.00;" |
| 15:47 |
|
Glasspasta_ |
oh |
| 15:48 |
|
Glasspasta_ |
i am setting the initial deposit |
| 15:48 |
|
Glasspasta_ |
that could me my problem |
| 15:48 |
|
aditsu |
actually you are changing the deposit amount that was passed to the method |
| 15:49 |
|
aditsu |
making it always deposit 0 |
| 15:49 |
|
Glasspasta_ |
oh ok |
| 15:50 |
|
Glasspasta_ |
i am not sure what my argument should be |
| 15:51 |
|
Glasspasta_ |
let me see |
| 15:52 |
|
Glasspasta_ |
so I am thinking it will work if I do not set the depAmount at all? |
| 15:53 |
|
aditsu |
well, it is set when the method is called |
| 15:53 |
|
aditsu |
you probably shouldn't set it inside the method |
| 15:54 |
|
aditsu |
when you call dep(12.34), depAmount becomes 12.34 |
| 15:54 |
|
Glasspasta_ |
ok link in my main method like Account customer1 = new Account; then call customer1(29.45); |
| 15:55 |
|
aditsu |
I don't think you can call customer1(29.45), because customer1 is an object, not a method |
| 15:55 |
|
Glasspasta_ |
oh ok sorry i am super new to java |
| 15:56 |
|
aditsu |
you can call a method on an object |
| 15:56 |
|
Glasspasta_ |
i see |
| 15:56 |
|
aditsu |
it's ok, you need to master the basic concepts |
| 15:57 |
|
aditsu |
if your dep method is from the Account class, you can probably call customer1.dep(29.45) |
| 15:57 |
|
Glasspasta_ |
oh ok i see |
| 15:57 |
|
aditsu |
you call "object.method(argument values)" |
| 15:58 |
|
Glasspasta_ |
cool i'll keep that info |
| 15:59 |
|
Glasspasta_ |
my other issue that each time someone make a deposit to their account i want to keep a count |
| 15:59 |
|
Glasspasta_ |
and do the same with the service fee |
| 15:59 |
|
Glasspasta_ |
does line 4 and 5 do that? |
| 16:00 |
|
Glasspasta_ |
to me it looks like it does |
| 16:00 |
|
aditsu |
well, you're incrementing deposits and service, it's good for counting, but I'm not sure how the service fee is supposed to be calculated |
| 16:00 |
|
Glasspasta_ |
oh |
| 16:01 |
|
aditsu |
if the service fee is 1 for each deposit, then that's fine |
| 16:01 |
|
aditsu |
but I don't know that it is :) |
| 16:01 |
|
Glasspasta_ |
yes it is |
| 16:01 |
|
Glasspasta_ |
oh ok |
| 16:01 |
|
aditsu |
ok then |
| 16:01 |
|
Glasspasta_ |
uhmmmm |
| 16:02 |
|
Glasspasta_ |
this is my variable : private double service = 1.00; |
| 16:02 |
|
aditsu |
I doubt that you should set it to 1 initially |
| 16:03 |
|
Glasspasta_ |
oh ok |
| 16:03 |
|
aditsu |
when you just start and don't have any transaction yet, I would expect it to be 0 (the default value) |
| 16:03 |
|
Glasspasta_ |
i see, then I can use a while loop to check if the depoit is at 1 yet? |
| 16:04 |
|
aditsu |
I mean.. if you're using it to accumulate all the service fees |
| 16:04 |
|
aditsu |
I'm not sure what you mean |
| 16:04 |
|
Glasspasta_ |
well i want the service fee to be 1.00 each time a deposit is made |
| 16:04 |
|
aditsu |
that's what service++ does |
| 16:05 |
|
aditsu |
it's adding 1 to service each time a deposit is made |
| 16:06 |
|
Glasspasta_ |
ok cool, i'm also trying to see why i am getting an error message saying Field service not used, isn't it being used in service++ |
| 16:08 |
|
aditsu |
error message? |
| 16:08 |
|
Glasspasta_ |
yes |
| 16:08 |
|
Glasspasta_ |
in netbeans |
| 16:08 |
|
Glasspasta_ |
not really an error message but a notification that service is not used |
| 16:09 |
|
aditsu |
maybe it's just a warning |
| 16:09 |
|
aditsu |
it's probably saying that you're not using the value of the service field, e.g. not displaying it anywhere, but you're only setting it |
| 16:10 |
|
Glasspasta_ |
oh ok |
| 16:10 |
|
Glasspasta_ |
thanks for the help, I'll keep working on my program :-) |
| 16:11 |
|
aditsu |
no problem |
| 16:11 |
|
Glasspasta_ |
hopefully it will work eventually |
| 16:11 |
|
Glasspasta_ |
:-) |
| 17:00 |
|
|
mr_lou joined ##friendlyjava |
| 17:11 |
|
|
Learner joined ##friendlyjava |
| 17:41 |
|
|
cn28h joined ##friendlyjava |
| 20:08 |
|
|
kirua joined ##friendlyjava |
| 20:29 |
|
|
kirua_ joined ##friendlyjava |