add test code from discussion after lecture

This commit is contained in:
Oleksii Aleshchenko 2023-02-16 16:30:11 +02:00
parent 81947f9b29
commit 9112df275b
4 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,14 @@
package encapsulationInheritancePolymorphism;
public class Main {
public static void main(String[] args) {
Student student = new Student();
//...
student.setFaculty("FPM", "MO-22");
}
}

View File

@ -3,8 +3,16 @@ package encapsulationInheritancePolymorphism;
public class Student { public class Student {
private String name; private String name;
private String surname; private String surname;
private String group;
private String faculty;
public String getName() { public String getName() {
return name; return name;
} }
public void setFaculty(String faculty, String group) {
this.faculty = faculty;
this.group = group;
}
} }

13
src/test/A.java Normal file
View File

@ -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;
}
}

15
src/test/Main.java Normal file
View File

@ -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);
}
}