View Single Post
  #2   Spotlight this post!  
Unread 20-11-2011, 21:15
rrossbach rrossbach is offline
Registered User
AKA: Ron R
FRC #2607 (RoboVikings)
Team Role: Mentor
 
Join Date: Nov 2008
Rookie Year: 2008
Location: Warrington PA
Posts: 90
rrossbach is a splendid one to beholdrrossbach is a splendid one to beholdrrossbach is a splendid one to beholdrrossbach is a splendid one to beholdrrossbach is a splendid one to beholdrrossbach is a splendid one to beholdrrossbach is a splendid one to behold
Re: extending CANJaguar subclass

Quote:
Originally Posted by rudun View Post
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.
In this case you need to explicitly define at least one constructor for your subclass (fps).

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 {
   
   public fps(int id) throws Exception {
         super(id);
   }

...
}
Hope that helps!

- Ron
Team #2607 controls mentor
__________________

FIRST Mid-Atlantic Volunteer
FRC Team #2607 Mentor
Reply With Quote