From 9112df275b42e680a45add648b7f76076d4939ea Mon Sep 17 00:00:00 2001 From: Oleksii Aleshchenko Date: Thu, 16 Feb 2023 16:30:11 +0200 Subject: [PATCH] add test code from discussion after lecture --- .../Main.java | 14 ++++++++++++++ .../Student.java | 8 ++++++++ src/test/A.java | 13 +++++++++++++ src/test/Main.java | 15 +++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 src/encapsulationInheritancePolymorphism/Main.java create mode 100644 src/test/A.java create mode 100644 src/test/Main.java diff --git a/src/encapsulationInheritancePolymorphism/Main.java b/src/encapsulationInheritancePolymorphism/Main.java new file mode 100644 index 0000000..47dc9d3 --- /dev/null +++ b/src/encapsulationInheritancePolymorphism/Main.java @@ -0,0 +1,14 @@ +package encapsulationInheritancePolymorphism; + +public class Main { + public static void main(String[] args) { + Student student = new Student(); + + + + + //... + + student.setFaculty("FPM", "MO-22"); + } +} diff --git a/src/encapsulationInheritancePolymorphism/Student.java b/src/encapsulationInheritancePolymorphism/Student.java index 8d931b9..2ad836d 100644 --- a/src/encapsulationInheritancePolymorphism/Student.java +++ b/src/encapsulationInheritancePolymorphism/Student.java @@ -3,8 +3,16 @@ package encapsulationInheritancePolymorphism; public class Student { private String name; private String surname; + private String group; + private String faculty; + public String getName() { return name; } + + public void setFaculty(String faculty, String group) { + this.faculty = faculty; + this.group = group; + } } diff --git a/src/test/A.java b/src/test/A.java new file mode 100644 index 0000000..8553a5e --- /dev/null +++ b/src/test/A.java @@ -0,0 +1,13 @@ +package test; + +public class A { + /*private*/ int f/* = 3*/; + + public int getF() { + return f; + } + + public void setF(int f) { + this.f = f; + } +} diff --git a/src/test/Main.java b/src/test/Main.java new file mode 100644 index 0000000..bf9f4b3 --- /dev/null +++ b/src/test/Main.java @@ -0,0 +1,15 @@ +package test; + +public class Main { + public static void main(String[] args) { + A a = new A(); + System.out.println(a.getF()); + a.setF(1); + System.out.println(a.getF()); + + System.out.println(a.f); + + int[] array = {1, 2, 1}; + System.out.println(array.length); + } +}