Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package model;
- /**
- *
- * @author phuon
- */
- public class Student implements Comparable<Student> {
- private String id;
- private String name;
- private int semester;
- private String courseName;
- public Student(String id, String name, int semester, String courseName) {
- this.id = id;
- this.name = name;
- this.semester = semester;
- this.courseName = courseName;
- }
- public String getSearchResult() {
- String lineFormat = "%-21s%10s%13s";
- return String.format(lineFormat, name, semester, courseName);
- }
- @Override
- public int compareTo(Student rhs) {
- if (this.id.equals(rhs.id)) {
- if (this.semester == rhs.semester) {
- return this.courseName.compareTo(rhs.courseName);
- }
- return this.semester - rhs.semester;
- }
- return this.id.compareTo(rhs.id);
- }
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getSemester() {
- return semester;
- }
- public void setSemester(int semester) {
- this.semester = semester;
- }
- public String getCourseName() {
- return courseName;
- }
- public void setCourseName(String courseName) {
- this.courseName = courseName;
- }
- }
Add Comment
Please, Sign In to add comment