Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. /**
  2.  * @(#)Obiektowka.java
  3.  *
  4.  * Obiektowka application
  5.  *
  6.  * @author
  7.  * @version 1.00 2019/1/19
  8.  */
  9.  
  10. public class Obiektowka {
  11.    
  12.     public static void main(String[] args) {
  13.         Person p1 = new Person("Janek","Nowak",14);
  14.         Student s1 = new Student(p1);
  15.         System.out.println(s1.toString());
  16.     }
  17. }
  18.  
  19. interface StudentIDSetting{
  20.     public void setStudentID();
  21. }
  22.  
  23. class Person{
  24.     private String name;
  25.     private String surname;
  26.     private int age;
  27.    
  28.     Person(String name , String surname, int age){
  29.         this.name = name;
  30.         this.surname = surname;
  31.         this.age = age;
  32.     }
  33.     public String toString(){
  34.         return ("Imie: " +name +" Nazwisko: " + surname +" Wiek: "+age);
  35.     }
  36.  
  37.  
  38. class Student implements StudentIDSetting{
  39.     private Person person;
  40.     private int studentID;
  41.     private String fieldOfStudy;
  42.     private int nextStudentID = 1234;
  43.     private boolean semesterCompleted = false;
  44.    
  45.    
  46.     public void Student(Person person){
  47.         setStudentID();
  48.         nextStudentID++;
  49.         this.person = person;
  50.     }
  51.     public void setFieldofStudy(){
  52.     }
  53.     public String getFieldOfStudy(){
  54.         return "ds";
  55.     }
  56.     public void completeSemester(){
  57.     }  
  58.     public String toString(){
  59.         return "whole";
  60.     }
  61.        
  62.     public void setStudentID(){
  63.     }
  64. }
  65.    
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement