Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,4 @@ bin/
.vscode/

### Mac OS ###
.DS_Store

# IntelliJ Idea
/.idea/
.DS_Store
58 changes: 58 additions & 0 deletions src/school/management/system/Main.java
Original file line number Diff line number Diff line change
@@ -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<Teacher> 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<Student> 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<School> 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());
}
}
57 changes: 57 additions & 0 deletions src/school/management/system/School.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package school.management.system;

import java.util.List;

public class School {
private List<Teacher> teachers;
private List<Student> students;
private static int totalMoneyEarned;
private int totalMoneySpent;

public School(List<Teacher> teachers, List<Student> students) {
this.teachers = teachers;
this.students = students;
this.totalMoneyEarned = 0;
this.totalMoneySpent = 0;
}

public void setTeachers(List<Teacher> teachers) {
this.teachers = teachers;
}

public void setStudents(List<Student> students) {
this.students = students;
}

public static void updateTotalMoneyEarned(int moneyEarned) {
totalMoneyEarned += moneyEarned;
}

public static void updateTotalMoneySpent(int moneySpent) {
totalMoneyEarned -= moneySpent;
}

public List<Teacher> getTeachers() {
return teachers;
}

public List<Student> 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);
}
}
52 changes: 52 additions & 0 deletions src/school/management/system/Student.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
32 changes: 32 additions & 0 deletions src/school/management/system/Teacher.java
Original file line number Diff line number Diff line change
@@ -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);
}
}