Skip to content

Commit

Permalink
3. Вызов конструктора родителя super(...);
Browse files Browse the repository at this point in the history
  • Loading branch information
Temzor committed Nov 28, 2023
1 parent 5568b03 commit 9adae4e
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/ru/j4j/inheritance/Base.java
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.");
}
}
9 changes: 9 additions & 0 deletions src/main/java/ru/j4j/inheritance/Child.java
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;
}
}
10 changes: 10 additions & 0 deletions src/main/java/ru/j4j/inheritance/Engineer.java
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;
}
}
10 changes: 10 additions & 0 deletions src/main/java/ru/j4j/inheritance/Parent.java
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;
}
}
9 changes: 9 additions & 0 deletions src/main/java/ru/j4j/inheritance/Profession.java
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;
}
}
10 changes: 10 additions & 0 deletions src/main/java/ru/j4j/inheritance/Programmer.java
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;
}
}
7 changes: 7 additions & 0 deletions src/main/java/ru/j4j/inheritance/User.java
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();
}
}

0 comments on commit 9adae4e

Please sign in to comment.