Advertisement
elsemTim

Group

Nov 15th, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.61 KB | None | 0 0
  1. package students.logic;
  2.  
  3. import java.text.DateFormat;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.text.Collator;
  7. import java.util.Date;
  8. import java.util.Locale;
  9.  
  10. public class Student implements Comparable {
  11.  
  12.     private int studentId;
  13.     private String firstName;
  14.     private String surName;
  15.     private String patronymic;
  16.     private Date dateOfBirth;
  17.     private char sex;
  18.     private int groupId;
  19.     private int educationYear;
  20.  
  21.     public Student(ResultSet rs) throws SQLException {
  22.         setStudentId(rs.getInt(1));
  23.         setFirstName(rs.getString(2));
  24.         setPatronymic(rs.getString(3));
  25.         setSurName(rs.getString(4));
  26.         setSex(rs.getString(5).charAt(0));
  27.         setDateOfBirth(rs.getDate(6));
  28.         setGroupId(rs.getInt(7));
  29.         setEducationYear(rs.getInt(8));
  30.     }
  31.  
  32.     public Date getDateOfBirth() {
  33.         return dateOfBirth;
  34.     }
  35.  
  36.     public void setDateOfBirth(Date dateOfBirth) {
  37.         this.dateOfBirth = dateOfBirth;
  38.     }
  39.  
  40.     public int getEducationYear() {
  41.         return educationYear;
  42.     }
  43.  
  44.     public void setEducationYear(int educationYear) {
  45.         this.educationYear = educationYear;
  46.     }
  47.  
  48.     public int getGroupId() {
  49.         return groupId;
  50.     }
  51.  
  52.     public void setGroupId(int groupId) {
  53.         this.groupId = groupId;
  54.     }
  55.  
  56.     public int getStudentId() {
  57.         return studentId;
  58.     }
  59.  
  60.     public void setStudentId(int studentId) {
  61.         this.studentId = studentId;
  62.     }
  63.  
  64.     public String getFirstName() {
  65.         return firstName;
  66.     }
  67.  
  68.     public void setFirstName(String firstName) {
  69.         this.firstName = firstName;
  70.     }
  71.  
  72.     public String getPatronymic() {
  73.         return patronymic;
  74.     }
  75.  
  76.     public void setPatronymic(String patronymic) {
  77.         this.patronymic = patronymic;
  78.     }
  79.  
  80.     public String getSurName() {
  81.         return surName;
  82.     }
  83.  
  84.     public void setSurName(String surName) {
  85.         this.surName = surName;
  86.     }
  87.  
  88.     public char getSex() {
  89.         return sex;
  90.     }
  91.  
  92.     public void setSex(char sex) {
  93.         this.sex = sex;
  94.     }
  95.  
  96.     public String toString() {
  97.         return surName + " " + firstName + " " + patronymic + ", "
  98.                 + DateFormat.getDateInstance(DateFormat.SHORT).format(dateOfBirth)
  99.                 + ", Группа ИД=" + groupId + " Год:" + educationYear;
  100.     }
  101.  
  102.     public int compareTo(Object obj) {
  103.         Collator c = Collator.getInstance(new Locale("ru"));
  104.         c.setStrength(Collator.PRIMARY);
  105.         return c.compare(this.toString(), obj.toString());
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement