inheritance - Parent/Child Constructor in java -


i keep getting error required:boolean; found:no arguments; reason:actual , formal arguments lists differ in length;

i know why is, because constructor in superclass , subclass don't match...but dont want make changes them if possible because it'll ruin rest of other classes , if need make changes i'd rather make changes lowrights class. point me in right direction?

public class lowrights extends securityrights {     private string name;      public lowrights(string n){         this.name = n;         boolean right = getright(); // added         setright(false); // added     }      public boolean setright(boolean right){         return right;     }      public string getname(){         return name;     }      public static void main(string[] a){     lowrights s= new lowrights("lisa");     system.out.print(s.getname() +" "+s.getsecret());                   }  } 

this super class:

public class securityrights { private boolean right; private boolean canreadsecret; string secret="the secret 42";    public securityrights(boolean r) {  r = right;  if (r) canreadsecret=true; else canreadsecret=false; }  boolean getright(){  return right; }  boolean canreadsecret(){  return canreadsecret; }  string getsecret(){  if (canreadsecret) return secret; else return "access denied"; }  } 

lowrights needs call super(right); or securityrights needs add constructor.

child classes need call thier parent constructors.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -