add test code from discussion after lecture
This commit is contained in:
		
							parent
							
								
									81947f9b29
								
							
						
					
					
						commit
						9112df275b
					
				
							
								
								
									
										14
									
								
								src/encapsulationInheritancePolymorphism/Main.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/encapsulationInheritancePolymorphism/Main.java
									
									
									
									
									
										Normal 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");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										13
									
								
								src/test/A.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/test/A.java
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										15
									
								
								src/test/Main.java
									
									
									
									
									
										Normal 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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user