Advertisement
Dimitar_Iliev

Ex-Student

Oct 14th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. package Student;
  2.  
  3. public class Student {
  4.  
  5.     private static int STUDENT_COUNT;
  6.     private String name;
  7.     private String course;
  8.     private String speciality;
  9.     private String university;
  10.     private String email;
  11.     private String phoneNumber;
  12.  
  13.  
  14.     public Student(String name, String course, String speciality, String university,String phoneNumber) {
  15.         this.name = name;
  16.         this.course = course;
  17.         this.speciality = speciality;
  18.         this.university = university;
  19.         this.email = null;
  20.         this.phoneNumber = phoneNumber;
  21.         STUDENT_COUNT++;
  22.     }
  23.  
  24.     public Student(String name, String course, String speciality, String university) {
  25.         this.name = name;
  26.         this.course = course;
  27.         this.speciality = speciality;
  28.         this.university = university;
  29.         this.email = null;
  30.         this.phoneNumber = null;
  31.         STUDENT_COUNT++;
  32.     }
  33.  
  34.     public Student(String name, String course, String speciality,
  35.                    String university, String email, String phoneNumber) {
  36.         this.name = name;
  37.         this.course = course;
  38.         this.speciality = speciality;
  39.         this.university = university;
  40.         this.email = email;
  41.         this.phoneNumber = phoneNumber;
  42.         STUDENT_COUNT++;
  43.     }
  44.  
  45.  
  46.     @Override
  47.     public String toString() {
  48.  
  49.         String result = String.format("Student: %s from %s with %s (%s)\n",
  50.                 this.name,this.course,this.speciality,this.university);
  51.  
  52.         if (this.email != null){
  53.             result += String.format("Email: %s",this.email);
  54.         }
  55.  
  56.         if (this.phoneNumber != null){
  57.             result+= String.format("PhoneImpl number: %s",this.phoneNumber);
  58.         }
  59.  
  60.         return result;
  61.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement