Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.87 KB | None | 0 0
  1.                                
  2. public class Student {
  3.  
  4. private String firstName;
  5. private float score1, score2, credits;
  6.  
  7. //Gets
  8. public String getFirstName()
  9. {
  10.     return firstName;
  11. }
  12.  
  13. public float getScore1()
  14. {
  15.     return score1;
  16. }
  17.  
  18. public float getScore2()
  19. {
  20.     return score2;
  21. }
  22.  
  23. public float getCredits()
  24. {
  25.     return credits;
  26. }
  27.  
  28. //Sets
  29. public void setScore1(float newScore1)
  30. {
  31.     if (newScore1 <= 20 && newScore1 >= 0)
  32.     {
  33.         score1 = newScore1;
  34.     }
  35.     else
  36.     {
  37.         System.out.println("The score must be between 0 and 20");
  38.     }
  39. }
  40. //-------------------------------------------------------------------
  41. public void setScore2(float newScore2)
  42. {
  43.     if (newScore2 <= 30 && newScore2 >= 0)
  44.     {
  45.         score2 = newScore2;
  46.     }
  47.     else
  48.     {      
  49.     }
  50. }
  51. //-------------------------------------------------------------------
  52. public void setCredits(float newCredits)
  53. {
  54.     if (newCredits <= 160)
  55.     {
  56.         credits = newCredits;
  57.     }
  58.     else
  59.     {
  60.         System.out.println("The credits must be at most 160");
  61.     }
  62. }
  63. //-------------------------------------------------------------------
  64. // constructors
  65. public Student(String newFirstName, float newScore1, float newScore2, float newCredits)
  66. {
  67.     firstName = newFirstName;
  68.    
  69.     if (score1 <= 20 && score1 >= 0)
  70.     {
  71.         score1 = newScore1;
  72.     }
  73.     else
  74.     {
  75.         score1 = 0;
  76.     }
  77.    
  78.     if (score2 <= 30 && score2 >= 0)
  79.     {
  80.         score2 = newScore2;
  81.     }
  82.     else
  83.     {
  84.         score2 = 0;
  85.     }
  86.    
  87.     if (credits <= 160)
  88.     {
  89.         credits = newCredits;
  90.     }
  91.     else
  92.     {
  93.         credits = -1;
  94.     }
  95. }
  96. //------------------------------------
  97. public Student(String newFirstName)
  98. {
  99.     firstName = newFirstName;
  100.     score1 = 0;
  101.     score2 = 0;
  102.     credits = -1;
  103. }
  104. //------------------------------------------------------------------------
  105. public Student(String newFirstName, float newScore1, float newScore2)
  106. {
  107.     firstName = newFirstName;
  108.     score1 = newScore1;
  109.     score2 = newScore2;
  110.     credits = -1;
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement