-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3. Вызов конструктора родителя super(...);
- Loading branch information
Showing
7 changed files
with
62 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,7 @@ | ||
package ru.j4j.inheritance; | ||
|
||
public class Base { | ||
public Base() { | ||
System.out.println("Default Base constructor."); | ||
} | ||
} |
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,9 @@ | ||
package ru.j4j.inheritance; | ||
|
||
public class Child extends Parent { | ||
private String patronymic; | ||
public Child(String name, int age, String patronymic) { | ||
super(name, age); | ||
this.patronymic = patronymic; | ||
} | ||
} |
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,10 @@ | ||
package ru.j4j.inheritance; | ||
|
||
public class Engineer extends Profession { | ||
private int experience; | ||
|
||
public Engineer(boolean degree, int experience) { | ||
super(degree); | ||
this.experience = experience; | ||
} | ||
} |
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,10 @@ | ||
package ru.j4j.inheritance; | ||
|
||
public class Parent { | ||
private String name; | ||
private int age; | ||
public Parent(String name, int age) { | ||
this.name = name; | ||
this.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,9 @@ | ||
package ru.j4j.inheritance; | ||
|
||
public class Profession { | ||
private boolean degree; | ||
|
||
public Profession(boolean degree) { | ||
this.degree = degree; | ||
} | ||
} |
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,10 @@ | ||
package ru.j4j.inheritance; | ||
|
||
public class Programmer extends Engineer { | ||
private String programLang; | ||
|
||
public Programmer(boolean degree, int experience, String programLang) { | ||
super(degree, experience); | ||
this.programLang = programLang; | ||
} | ||
} |
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,7 @@ | ||
package ru.j4j.inheritance; | ||
|
||
public class User extends Base { | ||
public static void main(String[] args) { | ||
User user = new User(); | ||
} | ||
} |