Click here to Skip to main content
15,888,079 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Quote:
4 errors found:
[line: 9]
Error: constructor Student in class person.Student cannot be applied to given types;
required: java.lang.String
found: java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String
reason: actual and formal argument lists differ in length
[line: 11]
Error: no suitable constructor found for Employee(java.lang.String,java.lang.String,java.lang.String,java.lang.String)
constructor person.Employee.Employee() is not applicable
(actual and formal argument lists differ in length)
constructor person.Employee.Employee(java.lang.String,java.lang.String,person.MyDate) is not applicable
(actual and formal argument lists differ in length)
[line: 13]
Error: no suitable constructor found for faculty(java.lang.String,java.lang.String,java.lang.String,java.lang.String)
constructor person.faculty.faculty() is not applicable
(actual and formal argument lists differ in length)
constructor person.faculty.faculty(java.lang.String,java.lang.String) is not applicable
(actual and formal argument lists differ in length)
[line: 15]
Error: no suitable constructor found for staff(java.lang.String,java.lang.String,java.lang.String,java.lang.String)
constructor person.staff.staff() is not applicable
(actual and formal argument lists differ in length)
constructor person.staff.staff(java.lang.String) is not applicable
(actual and formal argument lists differ in length)

package person;


public class person {
private String name, address, phone, email;

public person(){
}

public person(String name, String address, String phone, String email){
    this.name = name;
    this.address = address;
    this.phone = phone;
    this.email = email;
}

public String getName(){
 return name;
}
 
 public void setName(String name){
     
 this.name = name;
}
 
 public String getAddress(){
 return address;
}

 
 public void setAddress(String address){

 this.address = address;
}

 public String getPhone(){

 return phone;
}

 public void setPhone(String phone){

 this.phone = phone;
}

 public String getEmail(){

 return email;
 }
 
 public void setEmail(String email){
 this.email = email;
 }   

@Override
 public String toString(){
 return getClass().getName() + "\n" + name;
 }
}


package person;


public class Employee extends person{
 private String office,salary;
 private MyDate DATE_HIRED;
 
 public Employee(){
 }

 public Employee(String office, String salary, MyDate DATE_HIRED){
 this.office = office;
 this.salary = salary;
 this.DATE_HIRED = DATE_HIRED;
 }

 public String office(){
 return office;
 }

 public void setOffice(String office){
 this.office = office;
 }

 public String getSalary(){
 return salary;
 }

 public void setSalary(String salary){
 this.salary = salary;
 }

 public MyDate getMyDate(){

 return DATE_HIRED;
 }
 }


package person;


public class faculty extends Employee {
 private String office_hours, rank;
 public faculty(){
 }

 public faculty(String office_hours, String rank){
 this.office_hours = office_hours;
 this.rank = rank;
 }

 public String getOfficeHours(){
 return office_hours;
 }

 public void setOfficeHours(String office_hours){
 this.office_hours = office_hours;
 }

 public String getRank(){
 return rank;
 }

 public void setRank(String rank){

 this.rank = rank;
 }
 }


package person;


public class MyDate{
 private final int month, day, year;
public MyDate(int month, int day, int year){
 this.day = day;
 this.month =month;
 this.year = year;
}
}


package person;


    public class staff extends Employee{

 private String title;

public staff(){
 }

 public staff(String title){
 this.title = title;
 }

 public String getTitle(){
 return title;
 }

public void setTitle(String title){
 this.title =title;
 }
 }


package person;

public class test {

 public static void main(String[] args) {

 person person = new person("Luay a", "ELM", "1234567895", "Luay@hotmail.com");

 person Student = new Student("Bob A", "Tahlia Street", "9876543212", "ab@hotmail.com", "junior");

 person Employee = new Employee("Adam J", "221b B Street", "3692581478", "cd@hotmail.com");

 person faculty = new faculty("Sam F", "Anivia Street", "7412589636", "ef@hotmail.com");

 person staff = new staff("James I", "League Street", "7539512648", "gh@hotmail.com");

System.out.println(person.toString() + "\n");

 System.out.println(Student.toString() + "\n");

 System.out.println(Employee.toString() + "\n");

 System.out.println(faculty.toString() + "\n");

 System.out.println(staff.toString() + "\n");
}
}


What I have tried:

Everything up to my knowledge, which is still beginner-ish.
Posted
Updated 9-Apr-17 22:08pm
Comments
[no name] 9-Apr-17 17:52pm    
The errors are clear enough. You are trying to instantiate some classes with the wrong number of arguments passed to the constructor.

1 solution

Java
person Student = new Student("Bob A", "Tahlia Street", "9876543212", "ab@hotmail.com", "junior");

You have not declared a Student class anywhere in the above code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900