add test code from discussion after lecture
This commit is contained in:
parent
81947f9b29
commit
9112df275b
|
@ -0,0 +1,14 @@
|
|||
package encapsulationInheritancePolymorphism;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Student student = new Student();
|
||||
|
||||
|
||||
|
||||
|
||||
//...
|
||||
|
||||
student.setFaculty("FPM", "MO-22");
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue