Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.35 KB | None | 0 0
  1. /**
  2.  * Class for creating Student objects that include all important information.
  3.  *
  4.  * @author Ryan Lewis
  5.  * @version 1
  6.  */
  7.  
  8. public class Student
  9. {
  10.     // instance variables
  11.     private String studentId;
  12.     private String firstName;
  13.     private String lastName;
  14.     private String emailAddress;
  15.     private int age;
  16.     private int[] grades;
  17.    
  18.  
  19.     /**
  20.      * Constructor for objects of class Student
  21.      */
  22.     public Student(String studentId, String firstName, String lastName, String emailAddress, int age, int[] grades)
  23.     {
  24.         // initialise instance variables
  25.         setStudentId(studentId);
  26.         setFirstName(firstName);
  27.         setLastName(lastName);
  28.         setEmailAddress(emailAddress);
  29.         setAge(age);
  30.         setGrades(grades);
  31.     }
  32.    
  33.     //Mutators
  34.     /**
  35.      * Sets the student ID
  36.      *
  37.      * @param  number the Student's ID number
  38.      */
  39.     public void setStudentId(String studentId)
  40.     {
  41.         this.studentId = studentId;
  42.     }
  43.     public void setLastName(String lastName)
  44.     {
  45.         this.lastName = lastName;
  46.     }
  47.     public void setFirstName(String firstName)
  48.     {
  49.         this.firstName = firstName;
  50.     }
  51.     public void setEmailAddress(String emailAddress)
  52.     {
  53.         this.emailAddress = emailAddress;
  54.     }
  55.     public void setAge(int age)
  56.     {
  57.         this.age = age;
  58.     }
  59.     public void setGrades(int[] grades)
  60.     {
  61.         this.grades = grades;
  62.     }
  63.    
  64.     //Accessors
  65.     public String getStudentId()
  66.     {
  67.         return studentId;
  68.     }
  69.     public String getFirstName()
  70.     {
  71.         return firstName;
  72.     }
  73.     public String getLastName()
  74.     {
  75.         return lastName;
  76.     }
  77.     public String getEmailAddress()
  78.     {
  79.         return emailAddress;
  80.     }
  81.     public int getAge()
  82.     {
  83.         return age;
  84.     }
  85.     public int[] getGrades()
  86.     {
  87.         return grades;
  88.     }
  89.    
  90.     //Print method
  91.     public void print()
  92.     {
  93.         System.out.println(
  94.                 "Student ID:\t" + getStudentId() +
  95.                 "\tFirst Name:\t" + getFirstName() +
  96.                 "\tLast Name:\t" + getLastName() +
  97.                 "\tEmail Address:\t" + getEmailAddress() +
  98.                 "\tAge:\t" + getAge() +
  99.                 "\tGrades:\t" + getGrades()[0] + ", " + getGrades()[1] + ", " + getGrades()[2]);
  100.     }
  101.    
  102.    
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement