//NAME: Stella K. //DATE: Nov 15, 2007 //PURPOSE: Lab on objects, and file i/o, cs111 //MODIFICATION HISTORY: public class Student { //instance variables private String last; private String first; private String year; private String lecture; private String lab; //constructor //Creates a Student object out of the 5 components: //name, last name, year, lecture and lab section public Student(String lastName, String firstName, String year, String lectureSection, String labSection) { last = lastName; first = firstName; this.year = year; lecture = lectureSection; lab = labSection; } //Creates a Student object out of one string. The string should have the format: //lastName;firstName;year;lecture;lab; //This is an example: Alexander;Angie;2011;lec02;lab03; public Student(String info) { String[] res = info.split(";"); String l = res[0]; String f = res[1]; String y = res[2]; String lec = res[3]; String lab = res[4]; last = l; first = f; year = y; lecture = lec; this.lab = lab; } //Getter methods so we can have access to the private instance variables outside this class public String getFirstName() { return first; } public String getLastName() { return last; } public String getLab() { return lab; } public String getLecture() { return lecture; } public String getYear() { return year; } //returns the string representation of a Student object. Great nethod for testing purposes // and not only! public String toString() { //String s = first + " : " + last + " : " + year + " : " + lecture + " : " + lab; String s = first + " " + last + " year " + year + " is in " + lecture + " and " + lab; return s; } public static void main(String[] args) { Student s1 = new Student("Kakavouli", "Stella", "1995", "lec01", "lab0123"); Student s2 = new Student("Tjaden", "Brian", "0000", "lec01", "lab00"); //System.out.println(s1); //System.out.println(s2); Student s3 = new Student("Alexander;Angie;2011;lec02;lab03;"); //System.out.println(s3); } }