Advertisement
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 Report implements Comparable<Report> {
- private String studentName;
- private String courseName;
- private int totalOfCourses;
- public Report(String studentName, String courseName, int totalOfCourses) {
- this.studentName = studentName;
- this.courseName = courseName;
- this.totalOfCourses = totalOfCourses;
- }
- @Override
- public String toString() {
- String lineFormat = "%-21s%12s%18s";
- return String.format(lineFormat, studentName, courseName, totalOfCourses);
- }
- @Override
- public int compareTo(Report rhs) {
- if (this.studentName.equals(rhs.studentName)) {
- if (this.courseName.equals(rhs.courseName)) {
- return this.totalOfCourses - rhs.totalOfCourses;
- }
- return this.courseName.compareTo(rhs.courseName);
- }
- return this.studentName.compareTo(rhs.studentName);
- }
- public String getStudentName() {
- return studentName;
- }
- public void setStudentName(String studentName) {
- this.studentName = studentName;
- }
- public String getCourseName() {
- return courseName;
- }
- public void setCourseName(String courseName) {
- this.courseName = courseName;
- }
- public int getTotalOfCourses() {
- return totalOfCourses;
- }
- public void setTotalOfCourses(int totalOfCourses) {
- this.totalOfCourses = totalOfCourses;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement