import java.util.ArrayList;

public class Main {

    public static void main(String[] args) {
        // ArrayList are dynamic collections of objects (reference types only)
        ArrayList<Student> lesson = new ArrayList<>();
        // Adding some students
        lesson.add(new Student("Bob", 2.9));
        lesson.add(new Student("Dave", 3.2));
        lesson.add(new Student("Sally", 4.0));

        printStudents(lesson);              // print students
        Student tmp = lesson.remove(0);     // remove a student from position 0
        printStudents(lesson);
        lesson.add(tmp);                    // add back at in at the end
        printStudents(lesson);
        lesson.add(new Student("Bill", 3.7));// can add to collection at any time
        printStudents(lesson);

        //Swap Sally(1) and Bob(2)
        tmp = lesson.get(1);            // Place Sally in tmp
        lesson.set(1, lesson.get(2));   // Put Bob in Sally's position
        lesson.set(2, tmp);             // put tmp (Sally) in Bob's position
        printStudents(lesson);
    }

    public static void printStudents(ArrayList<Student> al) {
        System.out.println("Student\tGPA");
        System.out.println("-------\t-------");
        for (int i = 0; i < al.size(); i++) {
            al.get(i).println();
        }
        System.out.println();
    }
}

class Student {
    private String Name;
    private double GPA;

    public Student(String name, double gpa) {
        this.Name = name;
        this.GPA = gpa;
    }

    public String getName() {
        return this.Name;
    }

    public String getName(String newName) {
        return (this.Name = newName);
    }

    public double getGPA() {
        return this.GPA;
    }

    public double setGPA(double newGPA) {
        return (this.GPA = newGPA);
    }

    public void println() {
        System.out.printf("%s\t%f\n", this.Name, this.GPA);
    }
}