Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @(#)Obiektowka.java
- *
- * Obiektowka application
- *
- * @author
- * @version 1.00 2019/1/19
- */
- public class Obiektowka {
- public static void main(String[] args) {
- Person p1 = new Person("Janek","Nowak",14);
- Student s1 = new Student(p1);
- System.out.println(s1.toString());
- }
- }
- interface StudentIDSetting{
- public void setStudentID();
- }
- class Person{
- private String name;
- private String surname;
- private int age;
- Person(String name , String surname, int age){
- this.name = name;
- this.surname = surname;
- this.age = age;
- }
- public String toString(){
- return ("Imie: " +name +" Nazwisko: " + surname +" Wiek: "+age);
- }
- class Student implements StudentIDSetting{
- private Person person;
- private int studentID;
- private String fieldOfStudy;
- private int nextStudentID = 1234;
- private boolean semesterCompleted = false;
- public void Student(Person person){
- setStudentID();
- nextStudentID++;
- this.person = person;
- }
- public void setFieldofStudy(){
- }
- public String getFieldOfStudy(){
- return "ds";
- }
- public void completeSemester(){
- }
- public String toString(){
- return "whole";
- }
- public void setStudentID(){
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement