Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student {
- private String firstName;
- private float score1, score2, credits;
- //Gets
- public String getFirstName()
- {
- return firstName;
- }
- public float getScore1()
- {
- return score1;
- }
- public float getScore2()
- {
- return score2;
- }
- public float getCredits()
- {
- return credits;
- }
- //Sets
- public void setScore1(float newScore1)
- {
- if (newScore1 <= 20 && newScore1 >= 0)
- {
- score1 = newScore1;
- }
- else
- {
- System.out.println("The score must be between 0 and 20");
- }
- }
- //-------------------------------------------------------------------
- public void setScore2(float newScore2)
- {
- if (newScore2 <= 30 && newScore2 >= 0)
- {
- score2 = newScore2;
- }
- else
- {
- }
- }
- //-------------------------------------------------------------------
- public void setCredits(float newCredits)
- {
- if (newCredits <= 160)
- {
- credits = newCredits;
- }
- else
- {
- System.out.println("The credits must be at most 160");
- }
- }
- //-------------------------------------------------------------------
- // constructors
- public Student(String newFirstName, float newScore1, float newScore2, float newCredits)
- {
- firstName = newFirstName;
- if (score1 <= 20 && score1 >= 0)
- {
- score1 = newScore1;
- }
- else
- {
- score1 = 0;
- }
- if (score2 <= 30 && score2 >= 0)
- {
- score2 = newScore2;
- }
- else
- {
- score2 = 0;
- }
- if (credits <= 160)
- {
- credits = newCredits;
- }
- else
- {
- credits = -1;
- }
- }
- //------------------------------------
- public Student(String newFirstName)
- {
- firstName = newFirstName;
- score1 = 0;
- score2 = 0;
- credits = -1;
- }
- //------------------------------------------------------------------------
- public Student(String newFirstName, float newScore1, float newScore2)
- {
- firstName = newFirstName;
- score1 = newScore1;
- score2 = newScore2;
- credits = -1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement