![]() |
extending CANJaguar subclass
I am trying to add methods to help with reading our robots actual speed off of a CANJaguar in fps. The issue I am having now is that it is not building becasue it needs a constructor, but if I am inheriting the class shouldn't they already exist. What i want to be able to do is when i call a CANJaguar object, e.g. leftMotor.getFps(), it will return the fps data to me. This is my code so far.
Any help is greatly appreciated. Code:
/*Code:
init: |
Re: extending CANJaguar subclass
Quote:
Why? Because if you don't specify a constructor in a subclass, Java makes a default one for you that doesn't take any arguments. But that default no-argument constructor expects to call the no-argument constructor for all of the superclasses (CANJaguar in your case). CANJaguar doesn't have a no-argument constructor, only the two constructors CANJaguar(int, ControlMode) and CANJaguar(int). That's what the compiler error message is telling you - that CANJaguar has "no suitable constructor" for a default no-argument subclass constructor to call. So you need to do something like this: Code:
public class fps extends CANJaguar {- Ron Team #2607 controls mentor |
Re: extending CANJaguar subclass
Thanks Ron. It now works, and even my math which is always a culprit in slowing me down was right. Here is what the whole thing is to anyone intrested in using the encoder on the Jaguar to calculate fps.
Code:
/* |
| All times are GMT -5. The time now is 22:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi