HW 3: UCLA

Description

In this homework you are going to write 2 classes UCLAClass, UCLAStudent.

UCLAClass

It represents a class in UCLA. It has the following 3 states The class has no public member variable. You can have other private variables.
It has the following public methods and constructors:

UCLAStudent

It represents a UCLA student. There is no public member variable but you can have other private variables.
The class has the following public methods and constructor

Test program

After your complete the programs, use the following 2 programs to test your programs:
Test1:
public class Test1 {
    public static void main(String[] args) {
        UCLAClass c = new UCLAClass("PIC20A", 4, "Introduction of Java");
	System.out.println(c.getClassID());
	System.out.println(c.getClassTitle());
	System.out.println(c.getUnits());
	System.out.println();
	c.showInfo();
    }
}
Output should be:
PIC20A
Introduction of Java
4

Class ID: PIC20A
Class Title: Introduction of Java
Units: 4
Test2
public class Test2 {
    public static void main(String[] args) {
        UCLAStudent charles = new UCLAStudent(502111234, "Charles Li");
	UCLAClass pic20a = new UCLAClass("PIC20A", 4, "Introduction of Java");
	UCLAClass pic10a = new UCLAClass("PIC10A", 5, "Introduction of C++");
	UCLAClass math120 = new UCLAClass("MATH120", 3, "Number Theory");
	UCLAClass math111 = new UCLAClass("MATH111", 4, "Algebra");
	charles.add(pic20a, 'A');
	charles.add(pic10a, 'B');
	charles.add(math120, 'D');
	charles.add(math111,'F');
	charles.showStudentInfo();
	System.out.println();
	charles.showClasses();
	System.out.println();
	System.out.println("GPA is " + charles.gpa());
    }
}
Output
Student ID: 502111234
Name: Charles Li

PIC20A A
PIC10A B
MATH120 D
MATH111 F

GPA is 2.125

What to submit

Call your source code file UCLAStudent.java, UCLAClass.java. Put these files in your submit folder. Do not place this file inside another folder within your submit folder.

Remark

Solution

UCLAStudent.java, UCLAClass.java