Skip to content

Education Sydtem #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions EducationSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,30 @@ abstract class University implements EducationalInstitution {
public ArrayList<Student> students;

public boolean transferStudent(Student student, University university) {
if(this.students.contains(student)) {
return false;
}else {
this.students.remove(student);
university.students.add(student);
student.university = university;
university.studentCount++;
this.studentCount--;
return true;
}
}

University(String name, double tuitionFee) {
this.name = name;
this.tuitionFee = tuitionFee;
this.students = new ArrayList<>();
this.studentCount = 0;
}
University(String name, double tuitionFee, Student student) {
this.name = name;
this.tuitionFee = tuitionFee;
this.students = new ArrayList<>();
this.students.add(student);
this.studentCount++;
}
}

Expand All @@ -22,41 +43,57 @@ class Student implements EducationalInstitution {
private double balance;

public Student(String name, double balance, University university) {
setName(name);
setBalance(balance);
if(university.tuitionFee <= getBalance()) {
this.university = university;
university.students.add(this);
university.studentCount++;
}else {
System.out.println("Not Enough Balance");
}
}

@Override
public String displayInfo() {
return "Name: " + getName() + "\nUniversity: " + getUniversity().name + "\nBalance: " + getBalance();
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public University getUniversity() {
return university;
}
public void setBalance(double balance) {
this.balance = balance;
}

public double getBalance() {
return balance;
}
}

class SbuUniversity extends University {
public SbuUniversity(String name, double tuitionFee) {
super(name, tuitionFee);
}

@Override
public String displayInfo() {
return "SBU University\n" + "Tuition Fee: " + this.tuitionFee + "\nStudent Count: " + this.studentCount;
}
}

class SutUniversity extends University {

SutUniversity(String name, double tuitionFee) {
super(name, tuitionFee);
}

@Override
public String displayInfo() {

return "SUT University\n" + "Tuition Fee: " + this.tuitionFee + "\nStudent Count: " + this.studentCount;
}
}
}