This file contains hidden or 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
========================================================== | |
SIMPLE VERSION OF CAT CLASS: | |
========================================================== | |
package com.alex.oop; | |
class Cat { // do not change class name! | |
// поля: | |
String name; // кличка кота |
This file contains hidden or 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
package com.alex.constructors; | |
class Person { | |
String name; | |
String surname; | |
int age; | |
Person(String n, String s, int a) { | |
name = n; |
This file contains hidden or 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
package com.alex.constructors; | |
class Person { | |
String name; | |
String surname; | |
int age; | |
Person() { // конструктор без параметров | |
name = "Иван"; |
This file contains hidden or 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
package com.alex.destructors; | |
class Person { | |
String name; | |
String surname; | |
int age; | |
Person() { // конструктор без параметров | |
name = "Иван"; |
This file contains hidden or 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
package com.alex.constructors; | |
class Person { | |
String name; | |
String surname; | |
int age; | |
Person() { // конструктор без параметров | |
name = "Иван"; |
This file contains hidden or 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
package com.alex.constructors; | |
class Person { | |
String name = "Иван"; | |
String surname = "Иванов"; | |
int age = 25; | |
Person() { // конструктор без параметров |
This file contains hidden or 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
package com.alex.constructors; | |
class Person { | |
String name; | |
String surname; | |
int age; | |
Person() { // конструктор без параметров | |
this("Иван", "Иванов", 25); |
This file contains hidden or 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
package com.alex.constructors; | |
import java.util.Arrays; | |
class Person { | |
String name; | |
String surname; | |
int age; |
This file contains hidden or 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
package com.alex.encapsulation; | |
class Person { | |
Person ref = this; | |
String name; | |
String surname; | |
int age; |
This file contains hidden or 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
package com.alex.encapsulation; | |
import java.util.Date; | |
class Person { | |
private String name; | |
private Date birthday; | |
private boolean knowJava; |