Homework 3: Bruin

Assigment

This is an easy hw. You are going to write several classes. You should use this or super to simplify your program. If your program is unnecesary long, points will be taken off.
Here are all the classes

Date.java

You can have other private members.
Here is a sample test program
DateTest.java
public class DateTest {
    public static void main(String[] args) {
        Date date = new Date(2003, 1, 30);
        System.out.println(date.getYear());
        System.out.println(date.getMonth());
        System.out.println(date.getDay());
        System.out.println(date);
        
        date = new Date(2003, 11, 9);
        System.out.println(date.getYear());
        System.out.println(date.getMonth());
        System.out.println(date.getDay());
        System.out.println(date);
    }
}
Output
2003
1
30
2003/01/30
2003
11
9
2003/11/09

Bruin.java

You can have other private members.
BruinTest.java
public class BruinTest {
    public static void main(String[] args) {
        Date bday = new Date(1980,2,23);
        Date firstDay = new Date(2003, 9, 30);
        Bruin bruin = new Bruin("123123235", "Helen Smith", 'F', bday, firstDay);
        System.out.println(bruin);
    }
}
Output
ID: 123123235
Name: Helen Smith
Gender: F
Date of birth: 1980/02/23
In UCLA since: 2003/09/30

Student.java

The class extends Bruin. In addition to all the members given in Bruin, the class has information about all the UCLA classes that the student took and all the grades You can have as many private variables as you like.
StudentTest.java
public class StudentTest {
    public static void main(String[] args) {
        Date bday = new Date(1980,2,23);
        Date firstDay = new Date(2003, 9, 30);
        Student s = new Student("123123235", "Helen Smith", 'F', bday, firstDay);
        System.out.println("getTotalUnits(): " + s.getTotalUnits());
        System.out.println("getGPA(): " + s.getGPA());
        System.out.println();
        System.out.println(s);
        s.addClass("PIC10A", 5, "A-");
        s.addClass("PIC10B", 5, "B+");
        s.addClass("PIC20A", 5, "A");
        s.addClass("Math31A", 4, "C");
        System.out.println("getTotalUnits(): " + s.getTotalUnits());
        System.out.println("getGPA(): " + s.getGPA());
        System.out.println();
        System.out.println(s);
    }
}
Output
getTotalUnits(): 0
getGPA(): 0.0

ID: 123123235
Name: Helen Smith
Gender: F
Date of birth: 1980/02/23
In UCLA since: 2003/09/30
Class taken:
Total units: 0
GPA: 0.0

getTotalUnits(): 19
getGPA(): 3.32

ID: 123123235
Name: Helen Smith
Gender: F
Date of birth: 1980/02/23
In UCLA since: 2003/09/30
Class taken:
PIC10A  5       A-
PIC10B  5       B+
PIC20A  5       A
Math31A 4       C
Total units: 19
GPA: 3.32
StudentTest2
public class StudentTest2 {
    public static void main(String[] args) {
        Date bday = new Date(1984,2,23);
        Date firstDay = new Date(2004, 9, 30);
        Student s = new Student("144244422", "Mary Ford", 'F', bday, firstDay);
        s.addClass("PIC10A", 5, "C-");
        s.addClass("PIC10B", 5, "B");
        System.out.println(s);
        s.addClass("PIC10A", 5, "A") ; // replace the grade of PIC10A
        System.out.println(s);
    }
}
Output
ID: 144244422
Name: Mary Ford
Gender: F
Date of birth: 1984/02/23
In UCLA since: 2004/09/30
Class taken:
PIC10A  5       C-
PIC10B  5       B
Total units: 10
GPA: 2.35

ID: 144244422
Name: Mary Ford
Gender: F
Date of birth: 1984/02/23
In UCLA since: 2004/09/30
Class taken:
PIC10A  5       A
PIC10B  5       B
Total units: 10
GPA: 3.5

Professor.java

The class extends Bruin. It has the following variables: You can have other private variables.
ProfTest.java
public class ProfTest {
    public static void main(String[] args) {
        Date bday = new Date(1955,2,23);
        Date firstDay = new Date(1997, 10, 8);
        Professor prof  = new Professor("123123235", "Dava Johnson", 'M', bday, firstDay, Professor.ASSOCIATE);
        System.out.println(prof);
         firstDay = new Date(1997, 1,1);
        prof  = new Professor("123123235", "Dava Johnson", 'M', bday, firstDay, Professor.ASSOCIATE);
        System.out.println(prof);
    }
}
Output
ID: 123123235
Name: Dava Johnson
Gender: M
Date of birth: 1955/02/23
In UCLA since: 1997/10/08
Position: Associate Professor
Salary: 268019

ID: 123123235
Name: Dava Johnson
Gender: M
Date of birth: 1955/02/23
In UCLA since: 1997/01/01
Position: Associate Professor
Salary: 281420

Hint

What to submit

Call your source code file Date.java, Bruin.java, Student.java, Professor.java. Put this file in your submit folder. Do not place this file inside another folder within your submit folder.

Remark

Solution

Date.java, Bruin.java, Student.java, Professor.java