package com.javarush.test.level05.lesson12.home02;

/ A Man and A Woman 1. Create public static classes Man and Woman within the class Solution. 2. Classes must have fields: name(String), age(int), address(String). 3. Create constructors to pass all the possible parameters to. 4. Use the constructor to create two objects of each class with all the data. 5. Display the objects in format [name + " " + age + " " + address]. /

public class Solution { public static void main(String[] args) { //create two object of every class here man man1 = new man("zhang xiaolong", 24, "China wenzhou"); man man2 = new man("zhang zhongguang", 47, "China wenzhou"); woman woman1 = new woman("zhang tiantian", 24, "China wenzhou"); woman woman2 = new woman("chenaimei", 50, "China wenzhou");

    //output them to screen here
    System.out.println(man1.man);
    System.out.println(man2.man);
    System.out.println(woman1.woman);
    System.out.println(woman2.woman);
}

//add your classes here
public static class man
{
    private String name;
    private int age;
    private String address;
    private String man;

    public man(String name, int age, String address)
    {
        this.man = name + " " + age + " " + address;
    }

}

public static class woman
{
    private String name;
    private int age;
    private String address;
    private String woman;

    public woman(String name, int age, String address)
    {
        this.woman = name + " " + age + " " + address;
    }

}

}

The output is : zhang xiaolong 24 China wenzhou zhang zhongguang 47 China wenzhou zhang tiantian 24 China wenzhou chenaimei 50 China wenzhou

Process finished with exit code 0

but not passing the task.. help, please~

asked 23 Dec '15, 22:24

Tiantian%20Zhang's gravatar image

Tiantian Zhang
1
accept rate: 0%


public static void main(String[] args) { Man man = new Man("Maik",39,"Kyiv"); Woman woman = new Woman("Jain", 23,"Novaya Kachovka");//create two object of every class here

    System.out.println(man);//output them to screen here
    System.out.println(woman);//output them to screen here
}

public static class Man
{
    public String name;
    public int age;
    public String address;

    Man(String name,int age, String address)
    {
        this.name = name;
        this.age = age;
        this.address = address;
    }
}

public static class Woman
{
    public String name;
    public int age;
    public String address;

    Woman(String name,int age, String address)
    {
        this.name = name;
        this.age = age;
        this.address = address;
    }
}
link

answered 08 Sep, 04:14

Vladymyr's gravatar image

Vladymyr
1
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×30
×21
×3

Asked: 23 Dec '15, 22:24

Seen: 884 times

Last updated: 08 Sep, 04:14