Advertisement
Guest User

Untitled

a guest
Nov 8th, 2021
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.92 KB | None | 0 0
  1. class Student{
  2.     private int brojIndexa;
  3.     private String ime;
  4.     private String prezime;
  5.     private int godinaStudija;
  6.  
  7.     public Student(int brojIndexa,String ime,String prezime,int godinaStudija){
  8.         this.brojIndexa=brojIndexa;
  9.         this.ime=ime;
  10.         this.prezime=prezime;
  11.         this.godinaStudija=godinaStudija;
  12.     }
  13.  
  14.     public int getBrojIndexa() {
  15.         return brojIndexa;
  16.     }
  17.  
  18.  
  19.     public String getIme() {
  20.         return ime;
  21.     }
  22.  
  23.  
  24.     public String getPrezime() {
  25.         return prezime;
  26.     }
  27.  
  28.  
  29.     public int getGodinaStudija() {
  30.         return godinaStudija;
  31.     }
  32.  
  33.  
  34. }
  35.  
  36. public class Main {
  37.  
  38.  
  39.  
  40.     public static void main(String[] args) {
  41.     // write your code here
  42.  
  43.         Scanner scan = new Scanner(System.in);
  44.  
  45.        Student student1=new Student(1,"John","Doe",2);
  46.        Student student2=new Student(12,"Jane","Doe",4);
  47.        Student student3=new Student(13,"Jimmy","Doe",5);
  48.  
  49.  
  50.         System.out.println(student1.getBrojIndexa()+" -broj indexa student1");
  51.         System.out.println(student1.getIme()+" -ime student1");
  52.         System.out.println(student1.getPrezime()+" -prezime student1");
  53.         System.out.println(student1.getGodinaStudija()+" -godina studija student1");
  54.  
  55.         System.out.println("");
  56.  
  57.         System.out.println(student2.getBrojIndexa()+" -broj indexa student2");
  58.         System.out.println(student2.getIme()+" -ime student2");
  59.         System.out.println(student2.getPrezime()+" -prezime student2");
  60.         System.out.println(student2.getGodinaStudija()+" -godina studija student2");
  61.  
  62.         System.out.println("");
  63.  
  64.         System.out.println(student3.getBrojIndexa()+" -broj indexa student3");
  65.         System.out.println(student3.getIme()+" -ime student3");
  66.         System.out.println(student3.getPrezime()+" -prezime student3");
  67.         System.out.println(student3.getGodinaStudija()+" -godina studija student3");
  68.  
  69.  
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement