diff --git a/BerlinTelran/grp_10-170123-e-be/src/lesson2/Cat.java b/BerlinTelran/grp_10-170123-e-be/src/lesson2/Cat.java new file mode 100644 index 00000000..6c3c6c0a --- /dev/null +++ b/BerlinTelran/grp_10-170123-e-be/src/lesson2/Cat.java @@ -0,0 +1,37 @@ +package lesson2; + +public class Cat { + private String name; + private String color; + private int age; + + public Cat() { + } + + public Cat(String name, String color, int age) { + this.name = name; + this.color = color; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + String voice() { + return "meow"; + } + + @Override + public String toString() { + return "Cat{" + + "name='" + name + '\'' + + ", color='" + color + '\'' + + ", age=" + age + + '}'; + } +} diff --git a/BerlinTelran/grp_10-170123-e-be/src/lesson2/Lesson2.java b/BerlinTelran/grp_10-170123-e-be/src/lesson2/Lesson2.java new file mode 100644 index 00000000..0dae5ef8 --- /dev/null +++ b/BerlinTelran/grp_10-170123-e-be/src/lesson2/Lesson2.java @@ -0,0 +1,19 @@ +package lesson2; + +/** + * Java Proffessional + * @date 5.5.2023 + */ + +public class Lesson2 { + public static void main(String[] args) { + Cat cat = new Cat("Barsik", "black", 3); + System.out.println(cat.voice()); + System.out.println(cat); + cat.setName("Murzik"); + System.out.println("Name: " + cat.getName()); + System.out.println(cat); + + Cat catNull = new Cat(); + } +}