+ 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?
7 ответов
+ 18
● use static for variable amoutofCash & before method deposit.
//see the error messages there & then try to correct error.
+ 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.
+ 3
Gaurav Agrawal what is // here in your answer
+ 2
Hmm Thanks I forgot that protected was a thing haha
+ 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 ;-)
+ 1
Yeah Im just trying to stack up all the things I learned in SoloLearn, some may not be needed
0
Thanks !