#SavingsAccount() Construct vs deposit() Method

1 messages · Page 1 of 1 (latest)

timid salmon
#

Is the idea here to use UpperCamelCase naming convention to easily spot when you are working with a ClassName?

and lowerCamelCase to show you are working with a generic methodName?

SavingsAccount() is considered a "method"? Or strictly as a "constructor", which is a special type of method with no return type? (Important not to get those words mixed up, as they are VERY important to get right)

We use constructor to kind of "set up" an object? So that it's ready to be made into an object.

We use deposit() as a method to pass onto any SavingsAccount object? Since it does not include static I cannot pass the method onto the class directly, so I must create an object first using:
SavingsAccount myAccount = new SavingsAccount();
then I can use this method on the object, not the class, but the object itself:
myAccount.deposit(12.99)

Do I have all of that correct when it comes to looking at this code?

bitter raptorBOT
#

This post has been reserved for your question.

Hey @timid salmon! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

timid salmon
#

SavingsAccount() Construct vs deposit() Method

wide sapphire
real zodiac
#

deposit is not declared static so it will work for the object it was invoked on

#

But you should know that

#

balance can be declared private

#

And that it should have empty an line between your class and constructor separating the declared variable from both of them