Commit 39d2ee1d authored by nargessalehi98's avatar nargessalehi98

Add faculty

parents
import javax.swing.*;
/**
* this class is about course's data
*
* @author Narges
* @version 0.0
*/
public class Course {
// the name of course
private String name;
// the professor of course
private Professor professor;
// the list of course's student
private Student[] students;
// the list of course's lab
private Lab[] labs;
// the limit number of course capacity
private int maxCapacity;
// the number of current capacity
private int currentCapacity;
/**
* creat new course
*
* @param name name of course
* @param professor of course
* @param credit of course
*/
public Course(String name, Professor professor, int credit) {
students = new Student[15];
labs = new Lab[20];
this.name = name;
this.professor = professor;
credit = 4;
maxCapacity = 15;
}
/**
* @param name assign a name to course
*/
public void setName(String name) {
this.name = name;
}
/**
* @return name of course
*/
public String getName() {
return name;
}
/**
* @param professor set a professor to course
*/
public void setProfessor(Professor professor) {
this.professor = professor;
}
/**
* @return professor of the course
*/
public Professor getProfessor() {
return professor;
}
/**
* @param students list of course
*/
public void setStudents(Student[] students) {
this.students = students;
}
/**
* @return student list of course
*/
public Student[] getStudents() {
return students;
}
/**
* @param cap at the moment cap
*/
public void setCapacity(int cap) {
currentCapacity = cap;
}
/**
* @return current capacity of course
*/
public int getCurrentCapacity() {
return currentCapacity;
}
/**
* @return list of course's labs
*/
public Lab[] getLabs() {
return labs;
}
/**
* @param lab add lab to course's lab list
*/
public void addLab(Lab lab) {
for (int i = 0; i < labs.length; i++) {
if (labs[i] == null) {
labs[i] = lab;
}
}
}
/**
* @param student Add student in course and the first lab that has capacity
*/
public void enrollStudent(Student student) {
for (Lab lab : labs) {
if (lab.hasCapacity())
lab.enrollStudent(student);
else
System.out.println("Labs are full !");
}
}
public void printC() {
System.out.println("\nABOUT COURSE:Professor of course is:" + professor.getFirstName() +
"\nthe course's student are:" + getStudents() +
"\nthe course's capacity is :" + getCurrentCapacity() +
"\nthe course's lab is:" + getLabs());
}
}
import javax.swing.*;
/**
* this class act about a faculty
*
* @author Narges
* @version 0.0
*/
public class Faculty {
// name of faculty
private String name;
// list of professor of faculty
private Professor[] professors;
//list of faculty student
private Student[] students;
// list of courses of faculty
private Course[] courses;
/**
* creat a new faculty
*
* @param name of faculty
*/
public Faculty(String name) {
students=new Student[10];
professors=new Professor[10];
courses=new Course[10];
this.name = name;
}
/**
* @return name of faculty
*/
public String getName() {
return name;
}
/**
* @param students assign student to faculty
*/
public void setStudents(Student[] students) {
this.students = students;
}
/**
* @return students of the faculty
*/
public Student[] getStudents() {
return students;
}
/**
* @param courses assign courses to faculty's courses
*/
public void setCourses(Course[] courses) {
this.courses = courses;
}
/**
* @param professors assign professor to the faculty's professor
*/
public void setProfessors(Professor[] professors) {
this.professors = professors;
}
/**
* @return list of faculty's professors
*/
public Professor[] getProfessors() {
return professors;
}
/**
* @return list of faculty's courses
*/
public Course[] getCourses() {
return courses;
}
/**
* @param student enroll student to the faculty
*/
public void enrollStudent(Student student) {
for (int i = 0; i < students.length; i++) {
if (students[i] == null) {
students[i] = student;
}
}
}
/**
* @param course add a course to faculty
*/
public void addCourse(Course course) {
for (int i = 0; i < courses.length; i++) {
if (courses[i] == null) {
courses[i] = course;
}
}
}
/**
* @param professor add a professor to faculty
*/
public void addProfessor(Professor professor) {
}
/**
* @param student check out if this student is in the faculty
* @return true or false
*/
public boolean isStudentValid(Student student) {
for (Student value : students) {
return value == student;
}
return false;
}
/**
* @param course is a special course which is checking
* @return true of false
*/
public boolean isCourseValid(Course course) {
for (Course value : courses) {
return value == course;
}
return false;
}
/**
* @param professor name of special professor which is checking
* @return true of false
*/
public boolean isProfessorValid( Professor professor) {
for (Professor value : professors) {
return value == professor;
}
return false;
}
public void printF(){
System.out.println("\nABOUT FACULTY:the faculty name is :"+getName()+
"\nthe courses are:"+getCourses()+
"\nthe students are:"+getStudents()+
"\nthe professors are:"+getProfessors());
}
}
/**
* this class gives data about each course's lab
* @author Narges
* @version 0.0
*/
public class Lab {
// the lab's course
private Course course;
// the lab's TA
private String TA;
// the day which lab is working
private String day;
// list pf lab's student
private Student[] students;
//number of student whom enroll
private int currentSize;
// the limit of lac
private int capacity;
/**
* creat a new lab
* @param TA teacher assistant
* @param day the day which lab is working
* @param course the lab's name
* @param capacity the limit of lac
*/
public Lab(String TA, String day, Course course, int capacity){
students=new Student[10];
this.TA=TA;
this.day=day;
this.course=course;
currentSize=0;
capacity=15;
}
/**
* set a TA
* @param TA teacher assistant
*/
public void setTA(String TA){
this.TA=TA;
}
/**
* @return TA
*/
public String getTA(){
return TA;
}
/**
* @param day set a day for lab
*/
public void setDay(String day){
this.day=day;
}
/**
* return the lab's day
* @return day
*/
public String getDay(){
return day;
}
/**
* @param students set student to student list
*/
public void setStudents(Student[] students){
this.students=students;
}
/**
* return list of student
* @return students
*/
public Student[] getStudents(){
return students;
}
/**
* check out if there is capacity yet or not
* @return true or false
*/
public boolean hasCapacity(){
return currentSize < capacity;
}
/**
* @param currentSize of the lab
*/
public void setCurrentSize(int currentSize){
this.currentSize=currentSize;
}
/**
* @param student assign a new student to this lab
*/
public void enrollStudent(Student student){
if (currentSize < capacity) {
students[currentSize++] = student;
} else {
System.out.println("Lab is full!!!");
}
}
public void printL(){
System.out.println("\nABOUT LAB:lab's TA is :"+TA+
"\nthe current sizs is:"+currentSize+
"\nthe day is :"+day+
"\nhas capacity:"+hasCapacity()+
"\nthe students are :"+getStudents()+
"\n");
}
}
import javax.print.attribute.Size2DSyntax;
import javax.swing.plaf.IconUIResource;
public class Main {
public static void main(String[] args) {
Student S1 = new Student("Narges", "Salehi", "9628055");
Student S2 = new Student("maryam", "mohamadi", "9731022");
Professor EE = new Professor("Ehsan", "Edalat");
Course AP = new Course("AP", EE, 4 );
Course ML = new Course("ML", EE, 4);
Course DL=new Course("DL",EE,4 );
Lab APLAb = new Lab("TA", "saturday", AP, 15);
Faculty Computer = new Faculty("computer");
S1.setGrade(new int[]{12, 13, 14});
S1.calculateAverage();
S1.print();
EE.setCourses(new Course[]{AP, ML});
EE.addCourse(new Course("DL", EE, 4));
EE.setCourses(new Course[]{AP, ML,DL});
EE.printp();
APLAb.setTA("mana");
APLAb.setCurrentSize(13);
APLAb.setDay("saturday");
APLAb.hasCapacity();
APLAb.enrollStudent(S2);
APLAb.setStudents(new Student[]{S1});
APLAb.printL();
AP.setProfessor(new Professor("Narges", "Salehi"));
AP.setStudents(new Student[]{S1});
AP.setCapacity(13);
AP.addLab(APLAb);
AP.enrollStudent(S2);
AP.printC();
Computer.setCourses(new Course[]{AP,ML});
Computer.addCourse(new Course("DL",EE,4));
Computer.setCourses(new Course[]{AP,ML});
Computer.setStudents(new Student[]{S1});
Computer.setProfessors(new Professor[]{EE});
Computer.enrollStudent(S2);
Computer.addCourse(DL);
Computer.addProfessor(EE);
Computer.isCourseValid(DL);
Computer.isProfessorValid(EE);
Computer.isStudentValid(S1);
Computer.printF();
}
}
/**
* this class gives data about professor
*
* @author Narges
* @version 0.0
*/
public class Professor {
//name of professor
private String firstName;
// last name of professor
private String lastName;
// list of courses of professor
private Course[] courses;
/**
* creat a new professor
*
* @param firstName first name of professor
* @param lastName last name of professor
*/
public Professor(String firstName, String lastName) {
courses = new Course[10];
this.firstName = firstName;
this.lastName = lastName;
}
/**
* @return the first name of professor
*/
public String getFirstName() {
return firstName;
}
/**
* @return list of courses of a professor
*/
public Course[] getCourses() {
return courses;
}
/**
* @param courses assign courses
*/
public void setCourses(Course[] courses) {
this.courses = courses;
}
/**
* @param course add a course for a professor
*/
public void addCourse(Course course) {
for (int i = 0; i < courses.length; i++) {
if (courses[i] == null) {
courses[i] = course;
}
}
}
public void printp() {
System.out.println("About Professor : First name of professor is :" + firstName);
System.out.println("His courses are :");
for (Course cours : courses) {
System.out.println( cours.getName());
}
}
}
/**
* this student class present data about student
* @author Narges
* @version 0.0
*/
public class Student {
// student first name
private String firstName;
// student last name
private String lastName;
// student number
private String id;
// list of student grades
private int[] grades;
// the average of student grades
private int average;
// list of student courses
private Course[] courses;
/**
* creat new student with specific name and id
* @param fName first name
* @param lname last name
* @param sID student number
*/
public Student(String fName, String lname, String sID) {
firstName=fName;
lastName=lname;
id=sID;
courses=new Course[10];
}
/**
* @return first name of student
*/
public String getFirstName(){
return firstName;
}
/**
* @return last name of student
*/
public String getLastName(){
return lastName;
}
/**
* @return return id
*/
public String getId(){
return id;
}
/**
* @return student grades
*/
public int[] getGrades(){
return grades;
}
/**
* *
* @param num set the grade of student
*/
public void setGrade(int[] num) {
grades = num;
}
//All grades have equal weight
/**
* calculate the average of grades
*/
public void calculateAverage(){
int counter=0;
for (int grade : grades) {
average += grade;
counter++;
}
average=average/counter;
}
/**
* @return the average of grades
*/
public int getAverage(){
return average;
}
/**
* print the average of grades
*/
public void print(){
System.out.println("About Student : The average is:" +average);
System.out.println("\n");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment