Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. public class College implements Comparable
  2. {
  3. private String name;
  4. private String city;
  5. private String state;
  6. private int cost;
  7. private int yearFounded;
  8. private int undergradCount;
  9. private double gradRate;
  10.  
  11. public College(String n, String c, String s, int money, int y, int count, double rate)
  12. {
  13. name = n;
  14. city = c;
  15. state = s;
  16. cost = money;
  17. yearFounded = y;
  18. undergradCount = count;
  19. gradRate = rate;
  20. }
  21.  
  22. public int compareTo(Object other)
  23. {
  24. College otherCollege = (College) other;
  25. return this.getName().compareToIgnoreCase(otherCollege.getName());
  26. }
  27.  
  28. public String getName( )
  29. {
  30. return name;
  31. }
  32.  
  33.  
  34. public String getCity( )
  35. {
  36. return city;
  37. }
  38.  
  39. public String getState( )
  40. {
  41. return state;
  42. }
  43.  
  44. public int getCost( )
  45. {
  46. return cost;
  47. }
  48.  
  49. public int getYearFounded( )
  50. {
  51. return yearFounded;
  52. }
  53.  
  54. public int getEnroll( )
  55. {
  56. return undergradCount;
  57. }
  58.  
  59. public double getGradRate( )
  60. {
  61. return gradRate;
  62. }
  63.  
  64. public String toString()
  65. {
  66. return String.format("%-18s %-18s %2s %8d %8d %10d %9.1f ",
  67. name, city, state, cost, yearFounded, undergradCount, gradRate);
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement