• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Super class

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an error with my super class it is, Illegal start of type at line 133.
Any help would be great thanks
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The line super(iFirstName, iLastName) in your code is out of place. If your intent is to call a constructor of the super class, it must be the first line in the constructor of the derived class.
Eugene.
 
jon ladd
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I put this super(iFirstName, iLastName)right at the begging of the employee class and still gave me the same error.
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I put this super(iFirstName, iLastName)right at the begging of the employee class and still gave me the same error.
As Eugene stated, you have to put it as the first line of the Employee consturctor, not just at the top of the class. A super constructor can only be called from inside a subs constructor and it must be the first line of the constructor.
 
jon ladd
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class Employee extends Person {
super(iFirstName, iLastName);
private double payrate;
public void setPrate(double newPrate){ payrate = newPrate;}
public double getPrate() {
return payrate;
Is this the right location?
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope. You don't call super there. Put it in the constructor of the subclass Try it this way:
class Employee extends Person {
private double payrate;
public Employee(){
super(iFirstName, iLastName);
// statements in constructor
}
public void setPrate(double newPrate){ payrate = newPrate;}
public double getPrate() {
return payrate;
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope. You need to write an Employee constructor:
 
jon ladd
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks that helped out alot. But now I am looking at errors in my getPrate and payrate.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But now I am looking at errors in my getPrate and payrate.
Welcome to the glamorous world of programming.
 
jon ladd
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks alot for the help I see were I messed up.
The only other thing that confusing me is the error about my strings Class string not found in class Person at line, it does it at every place i have a string.
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java is case-sensitive: use String, not string.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have any more errors, please post your revised code along with the error message. Also, please clearly note which line causes the error. I don't know how to count past 10! Even if I did, I wouldn't want to.
 
jon ladd
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the help.
 
Look ma! I'm selling my stuff!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic