Question
Draw a of the UML class diagram and its relationship package edu.education; public class InvalidGPAException extends Exception { public InvalidGPAException(String s) { super(s); } }
Draw a of the UML class diagram and its relationship
package edu.education;
public class InvalidGPAException extends Exception {
public InvalidGPAException(String s) {
super(s); }
}
package edu.education;
import java.util.ArrayList;
public class Student extends Person {
private double GPA; private static int counter; private ArrayList
public Student(String firstName, String lastNam, String phoneNumber, String email, double GPA) throws InvalidGPAException {
super(firstName, lastNam, phoneNumber, email); this.setID(++counter); setGPA(GPA);
}
public double getGPA() { return GPA; }
public void setGPA(double gPA) throws InvalidGPAException {
if (!(gPA >= 0.0 && gPA <= 4.0)) { throw new InvalidGPAException("Invalid student GPA. A valid GPA value should be in the 0.0 to 4.0 range!"); } else { GPA = gPA; } }
public void addTeacher(Teacher teacher) { teachers.add(teacher); }
public void displayStudentInfo() {
System.out.println("Student ID: " + this.getID() + "\tStudent name: " + getFirstName() + " " + getLastName());
System.out.printf("%n %15s %15s %15s %20s %17s %23s %n", "Teacher ID", "First name", "Last name", "Phone number", "Email", "Salary"); System.out.println( " __________________________________________________________________________________________________________________________ "); for (Teacher t : teachers) { System.out.printf("%15d %15s %15s %20s %23s %18.2f %n", t.getID(), t.getFirstName(), t.getLastName(), t.getPhoneNumber(), t.getEmail(), t.getSalary()); }
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started