diff --git a/.gitignore b/.gitignore index 43e3b04..f68d109 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,4 @@ bin/ .vscode/ ### Mac OS ### -.DS_Store - -# IntelliJ Idea -/.idea/ +.DS_Store \ No newline at end of file diff --git a/src/school/management/system/Main.java b/src/school/management/system/Main.java new file mode 100644 index 0000000..1e56626 --- /dev/null +++ b/src/school/management/system/Main.java @@ -0,0 +1,58 @@ +package school.management.system; + +import java.util.ArrayList; +import java.util.List; + +public class Main { + public static void main(String[] args) { + // Teachers list + List teacherList = new ArrayList<>(); + teacherList.add(new Teacher(0001, "Imran Khan", 10000)); + teacherList.add(new Teacher(0002, "Javed Miandad", 7000)); + teacherList.add(new Teacher(0003, "Shane Warne", 8500)); + + // Students list + List studentList = new ArrayList<>(); + studentList.add(new Student(0001, "Wasim Akram", 5)); + studentList.add(new Student(0002, "Inzamam-ul-Haq", 4)); + studentList.add(new Student(0003, "Saqlain Mushtaq", 5)); + + // Schools list + List schoolList = new ArrayList<>(); + schoolList.add(new School(teacherList, studentList)); + + // Cricket school + School cricketSchool = schoolList.get(0); + System.out.println("cricketSchool School has earned $"+cricketSchool.getTotalMoneyEarned()+" so far."); + + // Teachers + Teacher skipper = teacherList.get(0); + Teacher baadeMian = teacherList.get(1); + Teacher warnie = teacherList.get(2); + + // Students + Student wasim = studentList.get(0); + Student inzi = studentList.get(1); + Student saqlain = studentList.get(2); + + // Student's fees payments + wasim.updateFeesPaid(5000); + System.out.println(wasim.getName()+" has paid $"+wasim.getFeesPaid()+" & cricketSchool School has earned $"+cricketSchool.getTotalMoneyEarned()+" so far."); + + inzi.updateFeesPaid(5000); + System.out.println(inzi.getName()+" has paid $"+inzi.getFeesPaid()+" & cricketSchool School has earned $"+cricketSchool.getTotalMoneyEarned()+" so far."); + + saqlain.updateFeesPaid(5000); + System.out.println(saqlain.getName()+" has paid $"+saqlain.getFeesPaid()+" & cricketSchool School has earned $"+cricketSchool.getTotalMoneyEarned()+" so far."); + + // Teacher's salary payments + skipper.setSalary(skipper.getSalary()); + System.out.println(skipper.getName()+" has been paid & the school's current balance is "+ cricketSchool.getTotalMoneyEarned()); + + baadeMian.setSalary(baadeMian.getSalary()); + System.out.println(baadeMian.getName()+" has been paid & the school's current balance is "+ cricketSchool.getTotalMoneyEarned()); + + warnie.setSalary(warnie.getSalary()); + System.out.println(warnie.getName()+" has been paid & the school's current balance is "+ cricketSchool.getTotalMoneyEarned()); + } +} diff --git a/src/school/management/system/School.java b/src/school/management/system/School.java new file mode 100644 index 0000000..4ef22b8 --- /dev/null +++ b/src/school/management/system/School.java @@ -0,0 +1,57 @@ +package school.management.system; + +import java.util.List; + +public class School { + private List teachers; + private List students; + private static int totalMoneyEarned; + private int totalMoneySpent; + + public School(List teachers, List students) { + this.teachers = teachers; + this.students = students; + this.totalMoneyEarned = 0; + this.totalMoneySpent = 0; + } + + public void setTeachers(List teachers) { + this.teachers = teachers; + } + + public void setStudents(List students) { + this.students = students; + } + + public static void updateTotalMoneyEarned(int moneyEarned) { + totalMoneyEarned += moneyEarned; + } + + public static void updateTotalMoneySpent(int moneySpent) { + totalMoneyEarned -= moneySpent; + } + + public List getTeachers() { + return teachers; + } + + public List getStudents() { + return students; + } + + public int getTotalMoneyEarned() { + return totalMoneyEarned; + } + + public int getTotalMoneySpent() { + return totalMoneySpent; + } + + public void addTeacher(Teacher teacher) { + this.teachers.add(teacher); + } + + public void addStudent(Student student) { + this.students.add(student); + } +} diff --git a/src/school/management/system/Student.java b/src/school/management/system/Student.java new file mode 100644 index 0000000..615921c --- /dev/null +++ b/src/school/management/system/Student.java @@ -0,0 +1,52 @@ +package school.management.system; + +import static school.management.system.School.updateTotalMoneyEarned; + +public class Student { + private int id; + private String name; + private int grade; + private int feesPaid; + private int feesTotal; + + public Student(int id, String name, int grade) { + this.feesPaid = 0; + this.feesTotal = 30000; + this.id = id; + this.name = name; + this.grade = grade; + } + + public void setGrade(int grade) { + this.grade = grade; + } + + public void updateFeesPaid(int feesPaid) { + this.feesPaid += feesPaid; + updateTotalMoneyEarned(feesPaid); + } + + public int getId() { + return this.id; + } + + public String getName() { + return this.name; + } + + public int getGrade() { + return this.grade; + } + + public int getFeesPaid() { + return this.feesPaid; + } + + public int getFeesTotal() { + return this.feesTotal; + } + + public int getDueFees() { + return feesTotal-feesPaid; + } +} diff --git a/src/school/management/system/Teacher.java b/src/school/management/system/Teacher.java new file mode 100644 index 0000000..4350c75 --- /dev/null +++ b/src/school/management/system/Teacher.java @@ -0,0 +1,32 @@ +package school.management.system; + +import static school.management.system.School.updateTotalMoneySpent; + +public class Teacher { + private int id; + private String name; + private int salary; + + public Teacher(int id, String name, int salary) { + this.id = id; + this.name = name; + this.salary = salary; + } + + public int getId() { + return this.id; + } + + public String getName() { + return this.name; + } + + public int getSalary() { + return this.salary; + } + + public void setSalary(int salary) { + this.salary += salary; + updateTotalMoneySpent(salary); + } +}