ΠΡΠ΄Π°Π΅Ρ ΠΎΡΠΈΠ±ΠΊΡ : "Π£ ΠΊΠ»Π°ΡΡΠ° Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±ΡΡΡ ΠΌΠ΅ΡΠΎΠ΄ initialize, ΠΏΡΠΈΠ½ΠΈΠΌΠ°ΡΡΠΈΠΉ Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠΎΠ² Π²Π΅Ρ, ΡΠ²Π΅Ρ ΠΈ ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΡΡΡΠΈΠΉ Π²ΡΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ ΠΊΠ»Π°ΡΡΠ°, ΠΊΡΠΎΠΌΠ΅ ΠΈΠΌΠ΅Π½ΠΈ ΠΈ Π°Π΄ΡΠ΅ΡΠ°."
package com.javarush.task.task05.task0510;
/*
ΠΠΎΡΠΊΠΎΠΈΠ½ΠΈΡΠΈΠ°ΡΠΈΡ
*/
public class Cat {
//Π½Π°ΠΏΠΈΡΠΈΡΠ΅ ΡΡΡ Π²Π°Ρ ΠΊΠΎΠ΄
/*
String name = null;
int weight = 3;
int age = 2;
String color = "black";
String address = null;
*/
String name = null;
int weight;
int age;
String color;
String address = null;
public void initialize(String name)
{
this.name = name;
age = 2;
color = "black";
weight = 2;
}
public void initialize(String name,int weight,int age)
{
this.name = name;
this.weight = weight;
this.age=age;
color = "black";
}
public void initialize(int age, String name)
{
this.name = name;
this.weight = 2;
this.age=age;
color = "black";
}
public void initialize(String color,int weight)
{
this.weight = weight;
this.age = 2;
this.color = color;
}
public void initialize(int weight,String color,String address)
{
this.weight = weight;
this.age = 2;
this.color = color;
this.address=address;
}
public static void main(String[] args) {
Cat cat = new Cat();
cat.initialize("white",2);
System.out.println(cat.address+cat.color+cat.weight+cat.age+cat.name);
}
}