public Human(String name, boolean sex, int age)
{
this.name = name;
this.sex = sex;
this.age = age;
}
once i call it in main method, how i have pass it in arugment("ss", bolean??, 12);package com.codegym.task.task07.task0724;
/*
Family census
*/
public class Solution {
public static void main(String[] args) {
// write your code here
Human h1 = new Human("s", boolean.true , 12 );
Human h2 = new Human("s", boolean.TRUE , 12);
Human h3 = new Human("s", boolean.TRUE , 12);
Human h4 = new Human("s", boolean.TRUE , 12);
Human h5 = new Human("s", boolean.TRUE , 12, "a", "b" );
Human h6 = new Human("s", boolean.TRUE , 12, "a", "b");
Human h7 = new Human("s", boolean.TRUE , 12, "a", "b");
Human h8 = new Human("s", boolean.TRUE , 12, "a", "b");
Human h9 = new Human("s", boolean.TRUE , 12, "a", "b");
System.out.println(Human.toString());
/*System.out.println(Human.toString());
System.out.println(Human.toString());
System.out.println(Human.toString());
System.out.println(Human.toString());
System.out.println(Human.toString());*/
}
public static class Human {
// write your code here
String name;
boolean sex;
int age;
static Human father, mother;
public Human(String name, boolean sex, int age)
{
this.name = name;
this.sex = sex;
this.age = age;
}
public Human(String name, boolean sex, int age, Human father, Human mother)
{
this.name = name;
this.sex = sex;
this.age = age;
Human.father/*.name*/ = father;
Human.mother/*.name*/ = mother;
}
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;
}
}
}