❔ Inheritance
hey so i have this inheritance assignment and i dont know how i am supposed to implement the derived class for banking because there is nothing associated with it so im a little confused, also if somoene could check my current code for the account class that would be great because im not sure if im doing this right
21 Replies
your
Amount
property should just be an auto-prop, no reason to give it a backing fielduhh what does that mean
sorry im not that familiar with this stuff
decimal Amount { get; set; }
is all you needso remoivng public itslef is fine?
or should i remove the instance variable as well
ohh
you mean like just intiialize the variable as that
without putting the stuffi n get and set
yep
and thus remove the backing field
just remove
private decimal amount;
and replace all references to it with Amount
instead
the Balance
method strikes me as weird. I dont think it should add the interest.
I dont see a purpose for the method at all tbh, but it is stated in the description that it must exist for some reasonoh alright
so how would you implement the derived classes
like what should change
but it never says what it should do or when it should be called, which is weird
it should just be the overriden interest method right?
either that, or have the class specify the interest rate
oh ok
so for the banking one, what should i even do
because there is no interest rate associated with it
and its just branching off to ones associated with interest rate
something like this
banking serves absolutely no purpose except to give checking and savings a baseclass, but idk
the hierarchy is a bit weird, and idk if this is a good fit for inheritance 😛
oh wait we did learn about abstract classes in the textbook
i just realied
thanks a lot
think i understand now
whats the diff ebtween virtual and abstract methods?
oh is it that virutal can be overriden?
yes
where do you learn the => thing
cuz i cant find that anywhere online
for override
nvm i see
why do u put the m in the end tho
oh wait i got that error and see lmao
m
is the decimal literal suffix
and the =>
is the body expression symbol 🙂woudlnt i need a constructor in each one
because i need to make objects out of this
implicit constructors 🙂
or add ones, it doesnt matter
yeah but i cant initialize objects
oh wait
is this right?
ill rename it to checking but
alright actually i finished it @Pobiega but thanks a lot for your help, def wouldnt have figured it out if not for your help 🙏
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.