+ 1

Error in my beginner's project (Bank Machine)

https://code.sololearn.com/cdLHumtCT316/?ref=app I'm trying to understand inheritance better, there's a problem with my bank machine code can you guya take a look at it?

15th Mar 2019, 3:03 AM
Calvis Huynh
Calvis Huynh - avatar
7 odpowiedzi
+ 18
● use static for variable amoutofCash & before method deposit. //see the error messages there & then try to correct error.
15th Mar 2019, 3:58 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 17
I'm a beginner as well, but as far as I know, you need to create an object of the child class in order to access the methods and variables of the parent class. BankMachine m = new BankMachine(); m.deposit(37.0); And you can also make the parent's variables and methods "protected" instead of "private", this way they will be seen only by the child classes.
15th Mar 2019, 5:10 AM
1Lory☕
1Lory☕ - avatar
+ 3
Gaurav Agrawal what is // here in your answer
15th Mar 2019, 5:36 AM
Saksham Jain
Saksham Jain - avatar
+ 2
Hmm Thanks I forgot that protected was a thing haha
15th Mar 2019, 5:17 AM
Calvis Huynh
Calvis Huynh - avatar
+ 1
Calvis Huynh I am looking at working version if I change in line 21 int to void (there is no returning value and no need for it in this setter method). With pin log 0 i am the mostly welcome with some other input not very much, and in any case bank catch me ;-)
15th Mar 2019, 5:59 AM
vlada
+ 1
Yeah Im just trying to stack up all the things I learned in SoloLearn, some may not be needed
15th Mar 2019, 6:19 AM
Calvis Huynh
Calvis Huynh - avatar
0
Thanks !
15th Mar 2019, 5:01 AM
Calvis Huynh
Calvis Huynh - avatar