Skip to content

Instantly share code, notes, and snippets.

@ProZhar
Created December 7, 2015 09:16
Show Gist options
  • Select an option

  • Save ProZhar/52e48cf4f6206349350b to your computer and use it in GitHub Desktop.

Select an option

Save ProZhar/52e48cf4f6206349350b to your computer and use it in GitHub Desktop.
com.javarush.test.level10.lesson11.home06
package com.javarush.test.level10.lesson11.home06;
/* Конструкторы класса Human
Напиши класс Human с 6 полями. Придумай и реализуй 10 различных конструкторов для него. Каждый конструктор должен иметь смысл.
*/
public class Solution
{
public static void main(String[] args)
{
}
public static class Human
{
private String name;
private String surname;
private int age;
private String address;
private int phone;
private String car;
public Human(String name)
{
this.name = name;
}
public Human(String name, String surname)
{
this.name = name;
this.surname = surname;
}
public Human(String name, String surname, int age)
{
this.name = name;
this.surname = surname;
this.age = age;
}
public Human(String name, String surname, int age, String address)
{
this.name = name;
this.surname = surname;
this.age = age;
this.address = address;
}
public Human(String name, String surname, int age, String address, int phone)
{
this.name = name;
this.surname = surname;
this.age = age;
this.address = address;
this.phone = phone;
}
public Human(String name, String surname, int age, String address, int phone, String car)
{
this.name = name;
this.surname = surname;
this.age = age;
this.address = address;
this.phone = phone;
this.car = car;
}
public Human(String surname, int age)
{
this.surname = surname;
this.age = age;
}
public Human(String surname, int age, String address)
{
this.surname = surname;
this.age = age;
this.address = address;
}
public Human(String surname, int age, String address, int phone)
{
this.surname = surname;
this.age = age;
this.address = address;
this.phone = phone;
}
public Human(String surname, int age, String address, int phone, String car)
{
this.surname = surname;
this.age = age;
this.address = address;
this.phone = phone;
this.car = car;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment