-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |