Can someone please explain this error? Based on what I understand of the code, it is correct.
com/codegym/task/task07/task0724/Solution.java:10: error: constructor Human in class com.codegym.task.task07.task0724.Solution.Human cannot be applied to given types;
Human GF1 = new Human ("Pops", true, 71);
^
required: no arguments
found: java.lang.String,boolean,int
reason: actual and formal argument lists differ in length
package com.codegym.task.task07.task0724;
/*
Family census
*/
public class Solution {
public static void main(String[] args) {
Human GF1 = new Human ("Pops", true, 71);
Human GF2 = new Human ("Gramps", true, 73);
Human GM1 = new Human ("Ma", false, 74);
Human GM2 = new Human ("Nana", false, 72);
Human father = new Human ("David", true, 48, GF1, GM1);
Human mother = new Human ("Mary", false, 46, GF2, GM2);
Human kid1 = new Human ("Jake", true, 18, father, mother);
Human kid2 = new Human ("Catherine", false, 16, father, mother);
Human kid3 = new Human ("David Lee", true, 14, father, mother);
GF1.toString();
GF2.toString();
GM1.toString();
GM2.toString();
father.toString();
mother.toString();
kid1.toString();
kid2.toString();
kid3.toString();// write your code here
}
public static class Human {
String name;
boolean sex;
int age;
Human father;
Human mother;// write your code here
public String toString() {
String text = "";
text += "Name: " + this.name;
text += ", sex: " + (this.sex ? "male" : "female");
text += ", age: " + this.age;
if (this.father != null)
text += ", father: " + this.father.name;
if (this.mother != null)
text += ", mother: " + this.mother.name;
return text;
}
}
}