Skip to content

Commit

Permalink
java prof lesson #2
Browse files Browse the repository at this point in the history
  • Loading branch information
biblelamp committed May 7, 2023
1 parent b6da8cc commit b71e141
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
37 changes: 37 additions & 0 deletions BerlinTelran/grp_10-170123-e-be/src/lesson2/Cat.java
Original file line number Diff line number Diff line change
@@ -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 +
'}';
}
}
19 changes: 19 additions & 0 deletions BerlinTelran/grp_10-170123-e-be/src/lesson2/Lesson2.java
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit b71e141

Please sign in to comment.