Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Class for creating Student objects that include all important information.
- *
- * @author Ryan Lewis
- * @version 1
- */
- public class Student
- {
- // instance variables
- private String studentId;
- private String firstName;
- private String lastName;
- private String emailAddress;
- private int age;
- private int[] grades;
- /**
- * Constructor for objects of class Student
- */
- public Student(String studentId, String firstName, String lastName, String emailAddress, int age, int[] grades)
- {
- // initialise instance variables
- setStudentId(studentId);
- setFirstName(firstName);
- setLastName(lastName);
- setEmailAddress(emailAddress);
- setAge(age);
- setGrades(grades);
- }
- //Mutators
- /**
- * Sets the student ID
- *
- * @param number the Student's ID number
- */
- public void setStudentId(String studentId)
- {
- this.studentId = studentId;
- }
- public void setLastName(String lastName)
- {
- this.lastName = lastName;
- }
- public void setFirstName(String firstName)
- {
- this.firstName = firstName;
- }
- public void setEmailAddress(String emailAddress)
- {
- this.emailAddress = emailAddress;
- }
- public void setAge(int age)
- {
- this.age = age;
- }
- public void setGrades(int[] grades)
- {
- this.grades = grades;
- }
- //Accessors
- public String getStudentId()
- {
- return studentId;
- }
- public String getFirstName()
- {
- return firstName;
- }
- public String getLastName()
- {
- return lastName;
- }
- public String getEmailAddress()
- {
- return emailAddress;
- }
- public int getAge()
- {
- return age;
- }
- public int[] getGrades()
- {
- return grades;
- }
- //Print method
- public void print()
- {
- System.out.println(
- "Student ID:\t" + getStudentId() +
- "\tFirst Name:\t" + getFirstName() +
- "\tLast Name:\t" + getLastName() +
- "\tEmail Address:\t" + getEmailAddress() +
- "\tAge:\t" + getAge() +
- "\tGrades:\t" + getGrades()[0] + ", " + getGrades()[1] + ", " + getGrades()[2]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement