/**************************************************************************
 * All classes together
 *************************************************************************/
/**************************************************************************
 * The Student class
 *************************************************************************/
class Student
{
    //the static fields

    private static int    classNumber = 175000;
    private static String className   = "Intro To Java";
    private static String instructor  = "Sam Sultan";
    private static int    nextID      = 1000;
    
    
    //the instance fields

    private int studentID;
    private String firstName, lastName, address, city, state, email;


    //the constructors

    Student(String firstName, String lastName)        //small constructor
    {
        this.firstName = firstName;
        this.lastName  = lastName;
        this.address   = "";
        this.city      = "";
        this.state     = "";
        this.email     = "";

        this.studentID = ++nextID;      //add 1 to nextId, and assign it to studentId

    }

    Student(String firstName, String lastName, String address, String city, String state, String email)
    {
        this(firstName,lastName);       //call the small constructor  
        this.address = address;
        this.city    = city;
        this.state   = state;
        this.email   = email;
    }


    //the getter methods

    static int getClassNumber()     //getter for static field
    {
        return(classNumber);
    }

    static String getClassName()
    {
        return(className);
    }

    static String getInstructor()
    {
        return(instructor);
    }

    int getStudentID()              //getter for instance field
    {
        return(studentID);
    }
    
    String getFirstName()
    {
        return(firstName);
    }

    String getLastName()
    {
        return(lastName);
    }

    String getFullName()
    {
        return(firstName + " " + lastName);  
    }

    String getAddress()
    {
        return(address);
    }

    String getCity()
    {
        return(city);
    }

    String getState()
    {
        return(state);
    }    

    String getEmail()
    {
        return(email);
    }


    //the setter methods

    static void setClassName(String name)
    {
        className = name;
    }

    static void setInstructor(String instructor)
    {
        Student.instructor = instructor;       //setter for a static field
    }

    void setFirstName(String firstName)
    {
        this.firstName = firstName;             //setter for an instance field 
    }

    void setLastName(String lastName)
    {
        this.lastName = lastName;
    }

    void setAddress(String address)
    {
        this.address = address;
    }

    void setCity(String city)
    {
        this.city = city;
    }

    void setState(String state)
    {
        this.state = state;
    }

    void setEmail(String email)
    {
        this.email = email;
    }


    //the toString() method used to print the objects

    public String toString ()
    {
        String data = "Course........: " + classNumber   + "\t" + className + "\tInstructor: " + instructor + "\n" +
                      "Student Number: " + studentID     + "\n" +
                      "Student Name..: " + getFullName() + "\n" +
                      "Address.......: " + address       + "\t" + city + "\t" + state + "\n" + 
                      "Email Addr....: " + email         + "\n";
        return (data);
    }
}


/**************************************************************************
 * The tester class
 *************************************************************************/
public class StudentTest
{
    public static void main(String[] args)
    {
        //instatiate 5 objects - 2 using the first constructor and the other 3 using the second one

        Student s1 = new Student("Fred","Smith");
        Student s2 = new Student("Tom","Jones");
        Student s3 = new Student("Bill","Anderson","10 Elm St.","Buffalo","NY","banderson@blah.com");
        Student s4 = new Student("Ellen","Wilson","13 4th Ave.","Boston","MA","ewilson@blah.edu");
        Student s5 = new Student("Mary","Holt","1 Front St.","Edison","NJ","mholt@blah.org");

        //print out the 5 objects

        System.out.println("Initial state of student records:\n");

        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
        System.out.println(s4);
        System.out.println(s5);

        //use setters to change the information for s1 and s2

        System.out.println("\nChanging data for student "+ s1.getFullName() + ":");

        s1.setAddress("88 12th St.");
        s1.setCity("Boise");
        s1.setState("ID");
        s1.setEmail("fsmith@blahblah.com");

        System.out.println(s1);

        System.out.println("\nChanging data for student "+ s2.getFullName() + ":");

        s2.setAddress("15 Oak Dr.");
        s2.setCity("Billings");
        s2.setState("MT");
        s2.setEmail("tjones@blahblah.edu");

        System.out.println(s2);

        // use getters to print out selected fields from the objects

        System.out.println("\nWe can also just get the student ids and their names.\n");

        System.out.println("Student ID: " + s1.getStudentID() + "\tName: " + s1.getFullName());
        System.out.println("Student ID: " + s2.getStudentID() + "\tName: " + s2.getFullName());
        System.out.println("Student ID: " + s3.getStudentID() + "\tName: " + s3.getFullName());
        System.out.println("Student ID: " + s4.getStudentID() + "\tName: " + s4.getFullName());
        System.out.println("Student ID: " + s5.getStudentID() + "\tName: " + s5.getFullName());

        //use a setter for a static field to change the class instructor

        Student.setInstructor("Steve Jobs");

        //print out the final version of all 5 objects

        System.out.println("\nHere is the complete student list again after our changes:\n");

        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
        System.out.println(s4);
        System.out.println(s5);
    }
}