• Post Reply Bookmark Topic Watch Topic
  • New Topic

Constructor with super(value) as first line - 'value' variable won't change!?  RSS feed

 
Eddie Shakarchi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys. But of a tricky one to explain this!
I have a class called SingleDelayEffect, which has a constructor: This gets the values from a class called SingleDelay. However SingleDelayEffect extends a class called AudioEffect. You can see here that i have used super(value) to add the value of 'fowardMemSize' to the contructor of AudioEffect. This is fine, but what if the forwardMemSize changes? Ordinarily (for a variable like 'feedback')i can juse ues a method like: to get the value of feedback from the SingleDelay class if this value changes. But because the value of forwardMemSize is calculated in SingleDelay, and passed over, it won't change. In the SingleDelay class, i'm making a new object each time:
I know the super(); call has to be the first line of the constructor so what do i do it this value varies
I know i made a pigs ear of explaing this so if any more info is needed i can reply straight away
Thank you!
[ April 06, 2004: Message edited by: Eddie Shakarchi ]
 
Eddie Shakarchi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should add that in fact i want super(forwardMemSize) to actually be whatever is set here:
 
Eddie Shakarchi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no one?
i think it's impossible, right?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The short answer (and I'm not sure why I need to explain this again, as this seems to me to be the identical question I've already answered) is to give the appropriate class (here, it's AudioEffect) a setXXX method, which can then be called from or on instances of SingleDelayEffect (the method will be inherited by this class.)
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are violating one of The Rules(TM).
Calling an overridable method on a 'this' (implied or not) reference from a constructor.
An overrideable method is defined as one that is non-private, non-static, non-final, a member of a non-final class with at least one non-private constructor.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!